Search code examples
oracle12crole

Grant role to new_user is not working in 12C


DBA_USER: create role test_2

DBA_user: grant create session, create any table, create any procedure to test_2;

grant succeeded.....

grant test_2 to new_user

now new_user:

create table items (item_number number(3) primary key, 
                    item_name varchar2(40), 
                    item_desp varchar2(20), 
                    item_qty number(3));

Error: you have insufficient privilege 

Solution

  • Exact Oracle error code would help, but first guess would be that new_user does not have privilege on SYSTEM (or other tablespace). It is not recommended to use SYSTEM tablespace in general, so let's create tablespace first.

    Create separate tablespace for user :

       create tablespace tbs_for_new_user
       datafile 'tbs_nu.dbf' size 50m;
    

    Then assign newly created tablespace to user as default

       alter user "NEW_USER"
       default tablespace "TBS_FOR_NEW_USER"
       temporaty tablespace "TEMP"
       account unlock; // if you did not unlock new_user account yet
    
       alter user "NEW_USER" quota 50000m on TBS_FOR_NEW_USER;
       alter user "NEW_USER" DEFAULT ROLE "TEST_2";
    

    Then try to create table.