nullnull使用PL/SQL获取创建用户的语句
在寫這篇文章之前,xxx已經寫過了幾篇關于改nullnull主題的文章,想要了解的朋友可以去翻一下之前的文章
????Create procedure:
create or replace procedure get_case_sqls_for_ddls_ver1 ascursor get_username isselect username from dba_users;beginfor l_user in get_username loopDBMS_OUTPUT.PUT_LINE('-----------------------');DBMS_OUTPUT.PUT_LINE('select (case');DBMS_OUTPUT.PUT_LINE(' when ((select count(*)');DBMS_OUTPUT.PUT_LINE(' from dba_users');DBMS_OUTPUT.PUT_LINE(' where username = ''' ||l_user.username || ''') > 0)');DBMS_OUTPUT.PUT_LINE(' then dbms_metadata.get_ddl (''USER'', ''' ||l_user.username || ''')');DBMS_OUTPUT.PUT_LINE(' else to_clob ('' -- Note: User not found!'')');DBMS_OUTPUT.PUT_LINE(' end ) "--Extracted_DDL" from dual');DBMS_OUTPUT.PUT_LINE('UNION ALL');DBMS_OUTPUT.PUT_LINE('-----------------------');DBMS_OUTPUT.PUT_LINE('select (case');DBMS_OUTPUT.PUT_LINE(' when ((select count(*)');DBMS_OUTPUT.PUT_LINE(' from dba_ts_quotas');DBMS_OUTPUT.PUT_LINE(' where username = ''' ||l_user.username || ''') > 0)');DBMS_OUTPUT.PUT_LINE(' then dbms_metadata.get_granted_ddl (''TABLESPACE_QUOTA'', ''' || l_user.username || ''')');DBMS_OUTPUT.PUT_LINE(' else to_clob ('' -- Note: No TS Quotas found!'')');DBMS_OUTPUT.PUT_LINE(' end ) from dual');DBMS_OUTPUT.PUT_LINE('UNION ALL');DBMS_OUTPUT.PUT_LINE('-----------------------');DBMS_OUTPUT.PUT_LINE('select (case');DBMS_OUTPUT.PUT_LINE(' when ((select count(*)');DBMS_OUTPUT.PUT_LINE(' from dba_role_privs');DBMS_OUTPUT.PUT_LINE(' where grantee = ''' ||l_user.username || ''') > 0)');DBMS_OUTPUT.PUT_LINE(' then dbms_metadata.get_granted_ddl (''ROLE_GRANT'', ''' || l_user.username || ''')');DBMS_OUTPUT.PUT_LINE(' else to_clob ('' -- Note: No granted roles found!'')');DBMS_OUTPUT.PUT_LINE(' end ) from dual');DBMS_OUTPUT.PUT_LINE('UNION ALL');DBMS_OUTPUT.PUT_LINE('-----------------------');DBMS_OUTPUT.PUT_LINE('select (case');DBMS_OUTPUT.PUT_LINE(' when ((select count(*)');DBMS_OUTPUT.PUT_LINE(' from dba_sys_privs');DBMS_OUTPUT.PUT_LINE(' where grantee = ''' ||l_user.username || ''') > 0)');DBMS_OUTPUT.PUT_LINE(' then dbms_metadata.get_granted_ddl (''SYSTEM_GRANT'', ''' || l_user.username || ''')');DBMS_OUTPUT.PUT_LINE(' else to_clob ('' -- Note: No System Privileges found!'')');DBMS_OUTPUT.PUT_LINE(' end ) from dual');DBMS_OUTPUT.PUT_LINE('UNION ALL');DBMS_OUTPUT.PUT_LINE('-----------------------');DBMS_OUTPUT.PUT_LINE('select (case');DBMS_OUTPUT.PUT_LINE(' when ((select count(*)');DBMS_OUTPUT.PUT_LINE(' from dba_tab_privs');DBMS_OUTPUT.PUT_LINE(' where grantee = ''' ||l_user.username || ''') > 0)');DBMS_OUTPUT.PUT_LINE(' then dbms_metadata.get_granted_ddl (''OBJECT_GRANT'', ''' || l_user.username || ''')');DBMS_OUTPUT.PUT_LINE(' else to_clob ('' -- Note: No Object Privileges found!'')');DBMS_OUTPUT.PUT_LINE(' end ) from dual');DBMS_OUTPUT.PUT_LINE('/');DBMS_OUTPUT.PUT_LINE('----------------------------------------------------------------------');end loop; end; / 每日一道理航行者把樹比作指引方向的路燈,勞動者把樹比作遮風擋雨的雨傘,詩人把樹比作筆下的精靈,而我卻要把樹比作教師,它就是為我們遮風擋雨的傘,指明方向的路燈,打開知識殿堂的金鑰匙。
????The above proc when called with the foll. will give the SQLs for all users:
????
set head off set pages 0 set serveroutput on size unlimited spool /tmp/sqls_gathered_frm_trial_run_1.sql exec get_case_sqls_for_ddls_ver1 spool off????These SQLs generated can in turn be run as follows to get the master-list of all the grants in the database:
????
spool /tmp/grants_by_running_trial3_ver0.0.sql conn / as sysdba set head off set long 1000000000 set pages 0 exec DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE); @/tmp/sqls_gathered_frm_trial_run_1.sql spool off????
文章結束給大家分享下程序員的一些笑話語錄: 一條狗在街上閑逛,看見櫥窗里一張告示:「招聘程序員。會編程,有團隊精神,至少精通兩種語言。均等機會。」
那條狗就進去申請,但是被拒絕了。
「我不能雇一條狗在公司里做事。」經理說。
狗不服氣,指著告示上「均等機會」幾字抗議。
經理沒法,嘆了口氣,不屑地問道:「你會編程嗎?」
那條狗默默地走到電腦前,編了個程序,運作準確。
「你有團隊精神嗎?」經理問。
那條狗掉頭看了看門外,一大群野狗在外面虎視耽耽。
「我真的不能雇狗做這份工作。」經理氣急敗壞地說。
「就算會編程、有團隊精神,但是我需要的雇員至少要能精通兩種語言。」
那條狗抬頭看著經理說:「喵-噢。」
轉載于:https://www.cnblogs.com/jiangu66/archive/2013/05/19/3087235.html
總結
以上是生活随笔為你收集整理的nullnull使用PL/SQL获取创建用户的语句的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android Studio使用说明
- 下一篇: MySQL5.5加主键锁读问题【转】