我有一个新的Oracle Express 11g实例。我试图在默认的db (xe)中创建一个带有Table和View的新架构。
我的剧本是:
create user XAuthority identified by mysecret;
alter session set current_schema = XAuthority;
create schema authorization XAuthority
create table CUSTOMER ( ID int, CUSTOMER text)
create view CUSTOMER_VIEW as select * from CUSTOMER
grant select on CUSTOMER_VIEW to xareadonly;但我发现了一个错误:
SQL : ORA-02421:缺少或无效的架构授权标识符02421。00000 -“缺失或无效架构授权标识符”*原因:架构名称丢失或在create语句的授权子句中不正确。*操作:如果名称存在,则必须与当前架构相同。
我熟悉Postgres和MySql,但似乎甲骨文完全不同。有人能告诉我这里出了什么问题吗?
发布于 2017-01-10 08:42:47
使用CREATE语句在单个事务中创建多个表和视图,并在自己的架构中执行多个授予。
你有很多问题。首先,您需要将CREATE SESSION系统特权授予新创建的用户。其次,您的数据类型在Oracle中是不兼容的(应将int转换为number,将text转换为varchar2)。
为了使用CREATE SCHEMA语句,您需要以您在语句上指定的用户身份连接到数据库。
问题是您没有通过更改会话以xauthority的形式连接到数据库。
SQL> conn sys/password
Connected.
SQL> create user XAuthority identified by mysecret;
User created.
SQL> alter session set current_schema = XAuthority;
Session altered.
SQL> create schema authorization XAuthority
create table CUSTOMER(ID number, CUSTOMER_name varchar2(20))
create view CUSTOMER_VIEW as select * from CUSTOMER
grant select on CUSTOMER_VIEW to xareadonly; 2 3 4
create schema authorization XAuthority
*
ERROR at line 1:
ORA-02421: missing or invalid schema authorization identifier
SQL> show user
USER is "SYS"用户应该是xauthority,但它仍然是SYS。
需要create session系统特权才能连接到数据库。
SQL> grant create session to xauthority;
Grant succeeded.您需要表空间上的配额来创建模式对象(如表)。
SQL> alter user xauthority quota unlimited on orapdb1_tbs1;
User altered.
SQL> conn xauthority/mysecret
Connected.
SQL> conn xauthority/mysecret
Connected.
SQL> create schema authorization XAuthority
create table CUSTOMER(ID number, CUSTOMER_name varchar2(20))
create view CUSTOMER_VIEW as select * from CUSTOMER;
Schema created.https://dba.stackexchange.com/questions/160517
复制相似问题