Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone user in Oracle

Have a need for a sql query which will do cloning of Oracle user. As source I have user which has all necessary privileges. I wonder if it is possible to create the same one, but with different username in the same database.

like image 820
Petro Semeniuk Avatar asked Dec 17 '10 06:12

Petro Semeniuk


1 Answers

Briefly (from here)

select dbms_metadata.get_ddl('USER', '...') FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL('ROLE_GRANT','...') FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','...') FROM DUAL;
SELECT DBMS_METADATA.GET_GRANTED_DDL('OBJECT_GRANT','...') FROM DUAL;
SELECT DBMS_METADATA.GET_granted_DDL('TABLESPACE_QUOTA', '...') FROM dual;

Then just replace the username with the new one you want to create.

like image 130
Gary Myers Avatar answered Sep 21 '22 17:09

Gary Myers