Oracle:将角色从一个数据库复制到另一个数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10288520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle: copy a role from one database to another?
提问by Mark Harrison
I would like to duplicate some roles from a production database to a test database.
我想将一些角色从生产数据库复制到测试数据库。
How can I programatically generate a text-based SQLPLUS script to do this? Since I'm only interested in the roles I don't want to use EXP/IMP.
如何以编程方式生成基于文本的 SQLPLUS 脚本来执行此操作?因为我只对角色感兴趣,所以我不想使用 EXP/IMP。
回答by Jens Schauder
DBMS_METADATA might be helpful: http://www.orafaq.com/wiki/DBMS_METADATA
DBMS_METADATA 可能会有所帮助:http: //www.orafaq.com/wiki/DBMS_METADATA
SELECT dbms_metadata.get_ddl('ROLE', role) FROM dba_roles;
SELECT dbms_metadata.get_granted_ddl('ROLE_GRANT', '&&your_role_name') FROM dual;
SELECT dbms_metadata.get_granted_ddl('SYSTEM_GRANT','&&your_role_name') FROM dual;
SELECT dbms_metadata.get_granted_ddl('OBJECT_GRANT','&&your_role_name') FROM dual;