This post was sponsored by Technimove
I was reminded recently that Datapump does not export permissions on objects owned by SYS so I decided to write a post about it for my blog. It was tested on an Oracle 11.2.0.1 database. First I created a user called USER1:
SQL> conn / as sysdba
Connected.
SQL> create user user1
2 identified by user1
3 /
User created.
SQL> grant create session to user1
2 /
Grant succeeded.
SQL>
I logged in as USER1 and showed that it did not have execute permission on SYS.DBMS_LOCK:
SQL> conn user1/user1
Connected.
SQL> exec dbms_lock.sleep(1);
BEGIN dbms_lock.sleep(1); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_LOCK' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL>
I granted permission then logged in as USER1 again to check it had worked:
SQL> conn / as sysdba
Connected.
SQL> grant execute on dbms_lock to user1
2 /
Grant succeeded.
SQL> conn user1/user1
Connected.
SQL> exec dbms_lock.sleep(1);
PL/SQL procedure successfully completed.
SQL>
I used expdp to export the schema with the following parameters:
content=all
directory=andrews_datapump_dir
dumpfile=andrew.dmp
logfile=andrew_exp.log
schemas=user1
I used impdp to import the dumpfile into a different schema with the following parameters:
content=all
directory=andrews_datapump_dir
dumpfile=andrew.dmp
logfile=andrew_imp.log
remap_schema=user1:user2
…but when I logged in as USER2, it did not have execute permission on SYS.DBMS_LOCK:
SQL> conn user2/user1
Connected.
SQL> exec dbms_lock.sleep(1);
BEGIN dbms_lock.sleep(1); END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'DBMS_LOCK' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SQL>
No comments:
Post a Comment