下面为您介绍的是Oracle只读用户角色的建立方法,该方法供您参考,如果您在Oracle只读用户角色方面遇到过问题,不妨一看。
Oracle只读用户角色的建立的脚本:
1.授予某模式下对象读权限给角色。
- SET PAGESIZE 0
- SET FEEDBACK OFF
- SET VERIFY OFF
- SPOOL s.sql
- SELECT 'GRANT SELECT ON "' || u.object_name || '" TO &1;'
- FROM user_objects u
- WHERE u.object_type IN ('TABLE','VIEW','SEQUENCE')
- AND NOT EXISTS (SELECT '1'
- FROM all_tab_privs a
- WHERE a.grantee = UPPER('&1')
- AND a.privilege = 'SELECT'
- AND a.table_name = u.object_name);
- SPOOL OFF
- -- Comment out following line to prevent immediate run @s.sql
- SET PAGESIZE 14
- SET FEEDBACK ON
- SET VERIFY ON
2.为模式权限对象创建同意词。
- SET PAGESIZE 0
- SET FEEDBACK OFF
- SET VERIFY OFF
- SPOOL temp.sql
- SELECT 'CREATE SYNONYM "' || a.table_name || '" FOR "' || a.owner || '"."' || a.table_name || '";'
- FROM all_tables a
- WHERE NOT EXISTS (SELECT '1'
- FROM user_synonyms u
- WHERE u.synonym_name = a.table_name
- AND u.table_owner = UPPER('&1'))
- AND a.owner = UPPER('&1');
- SPOOL OFF
- -- Comment out following line to prevent immediate run
- @temp.sql
- SET PAGESIZE 14
- SET FEEDBACK ON
- SET VERIFY ON
以上就是Oracle只读用户角色的建立方法介绍。
【编辑推荐】