使用我创建的用户连接到数据库时遇到一些问题。首先,我创建了这样的用户:
create user util1 identified by user1;
create user util2 identified by user2;
create user util3 identified by user3;
create user util4 identified by user4;
create user util5 identified by user5;
create user util6 identified by user6;
create user util7 identified by user7;
create user util8 identified by user8;
grant dba to util1,util2,util3,util4,util5,util6,util7,util8;
select lpad(' ', 2*level) || granted_role "User, his roles and privileges"
from (select null grantee, username granted_role from dba_users where username like upper('%UTIL%')
union
select grantee, granted_role from dba_role_privs
union
select grantee, privilege from dba_sys_privs)
start with grantee is null
connect by grantee = prior granted_role;
这工作正常。但是当我尝试使用“util1”的权限创建一个表时,它不起作用:
connect util1/user1 AS SYSDBA;
create table pr1(
cod_subansamblu number(4),
denumire varchar2(20) not null,
cantitate number(7,3),
UM varchar2(3),
pret_unitar number(9,2),
cod_ansamblu number(4),
cod_sectie number(4) not null,
constraint pr1_cod_subansamblu_pk primary key(cod_subansamblu),
constraint pr1_UM_chk check(UM in ('BUC','ML','MP','MC','SET'))
);
我真的不知道出了什么问题。非常感谢帮助。
我收到的错误消息是:
Last Execution Details
Results
Statistics Plan
ORA-00900: invalid SQL statement
答案 0 :(得分:2)
CREATE TABLE语句没有错:
SQL> create table pr1(
cod_subansamblu number(4),
denumire varchar2(20) not null,
cantitate number(7,3),
UM varchar2(3),
pret_unitar number(9,2),
cod_ansamblu number(4),
cod_sectie number(4) not null,
constraint pr1_cod_subansamblu_pk primary key(cod_subansamblu),
constraint pr1_UM_chk check(UM in ('BUC','ML','MP','MC','SET'))
); 2 3 4 5 6 7 8 9 10 11
Table created.
SQL>
因此很难理解为什么它在运行时会抛出ORA-00900。你用什么客户来运行它?在SQL * Plus?像TOAD一样的IDE?你能提供一个完整会话的cut'n'paste所以我们可以看到完全发生了什么?
要记住的另一件事是,如果使用as sysdba
进行连接,则无论是否在CONNECT字符串中指定用户,都以SYS身份登录数据库:
SQL> conn apc/password as sysdba
Connected.
SQL> sho user
USER is "SYS"
SQL>
(仅当您以oracle
帐户或其他适当特权用户身份登录操作系统时才有效。
因此,您可能认为您正在将您的create table语句作为UTIL1运行,但实际上您将其作为SYS运行,这不是一个好主意。事实上,这是不好的做法。