在oracle中为用户创建一个角色和角色的表

时间:2017-01-20 18:46:32

标签: oracle

我正在创建一个角色名称开发者

create role developer ;
grant create session,create table to developer 

然后我又创建了一个用户

create user dhoni identified by dhoni 

授予dhoni的角色

grant role developer to dhoni ;
create table xx(sno number(11));

它没有创建表

 the error 
ORA-01031: insufficient privileges

2 个答案:

答案 0 :(得分:1)

grant role developer to dhoni ;

这无效 - 应该是

grant developer to dhoni;

然后您的创建表将起作用。

答案 1 :(得分:0)

可能在下面的解决方案中会有所帮助。

SQL> show user
USER is "SYS"
SQL>

SQL> create role developer;

Role created.

SQL> grant create session,create table to developer;

Grant succeeded.

SQL> create user dhoni identified by dhoni;

User created.

SQL> grant developer to dhoni;

Grant succeeded.

SQL> conn dhoni/dhoni
Connected.

SQL> show user
USER is "DHONI"

SQL> CREATE TABLE Persons (
    PersonID int,
    LastName varchar(255),
    FirstName varchar(255),
    Address varchar(255),
    City varchar(255)
);  2    3    4    5    6    7

Table created.

SQL>