如何在 Oracle 中克隆用户

2021-12-24 00:00:00 sql database oracle plsql

需要一个 sql 查询来克隆 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.

推荐答案

Briefly(来自 这里)

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.

相关文章