如何查詢Oracle中使用者所有資訊

來源:互聯網
上載者:User

標籤:

1.查看所有使用者:

  select * from dba_users;     select * from all_users;     select * from user_users;  2.查看使用者或角色系統許可權(直接賦值給使用者或角色的系統許可權):  select * from dba_sys_privs;     select * from user_sys_privs; (查看目前使用者所擁有的許可權)  3.查看角色(只能查看登陸使用者擁有的角色)所包含的許可權  sql> select * from role_sys_privs;  4.查看使用者物件許可權:  select * from dba_tab_privs;     select * from all_tab_privs;     select * from user_tab_privs;  5.查看所有角色: select * from dba_roles;  6.查看使用者或角色所擁有的角色:  select * from dba_role_privs;     select * from user_role_privs;  7.查看哪些使用者有sysdba或sysoper系統許可權(查詢時需要相應許可權)  select * from V$PWFILE_USERS  8.SqlPlus中查看一個使用者所擁有許可權  SQL> select * from dba_sys_privs where grantee= ‘username‘ ; 其中的username即使用者名稱要大寫才行。  比如: SQL> select * from dba_sys_privs where grantee= ‘TOM‘ ;  9、Oracle刪除指定使用者所有表的方法  select ‘Drop table ‘ ||table_name|| ‘;‘ from all_tables where owner= ‘要刪除的使用者名稱(注意要大寫)‘ ;  10、刪除使用者  drop user user_name cascade ; 如: drop user SMCHANNEL CASCADE  11、擷取目前使用者下所有的表:  select table_name from user_tables;  12、刪除某使用者下所有的表資料:  select ‘truncate table  ‘ || table_name from user_tables;  13、禁止外鍵 ORACLE資料庫中的外鍵約束名都在表user_constraints中可以查到。  其中constraint_type= ‘R‘ 表示是外鍵約束。  啟用外鍵約束的命令為: alter table table_name enable constraint constraint_name   禁用外鍵約束的命令為: alter table table_name disable constraint constraint_name  然後再用SQL查出資料庫中所以外鍵的約束名:  select ‘alter table ‘ ||table_name|| ‘ enable constraint ‘ ||constraint_name|| ‘;‘ from user_constraints where constraint_type= ‘R‘  select ‘alter table ‘ ||table_name|| ‘ disable constraint ‘ ||constraint_name|| ‘;‘ from user_constraints where constraint_type= ‘R‘  14、ORACLE禁用/啟用外鍵和觸發器 --啟用指令碼  SET SERVEROUTPUT ON SIZE 1000000  BEGIN  for c in ( select ‘ALTER TABLE ‘ ||TABLE_NAME|| ‘ ENABLE CONSTRAINT ‘ ||constraint_name|| ‘ ‘ as v_sql from user_constraints  where CONSTRAINT_TYPE= ‘R‘ ) loop  DBMS_OUTPUT.PUT_LINE(C.V_SQL);  begin  EXECUTE IMMEDIATE c.v_sql;    exception when others then    dbms_output.put_line(sqlerrm);    end ;  end loop;   for c in ( select ‘ALTER TABLE ‘ ||TNAME|| ‘ ENABLE ALL TRIGGERS ‘ AS v_sql from tab where tabtype= ‘TABLE‘ ) loop    dbms_output.put_line(c.v_sql);    begin    execute immediate c.v_sql;    exception when others then    dbms_output.put_line(sqlerrm);    end ;  end loop;  end ;  /   commit ;  --禁用指令碼  SET SERVEROUTPUT ON SIZE 1000000  BEGIN  for c in ( select ‘ALTER TABLE ‘ ||TABLE_NAME|| ‘ DISABLE CONSTRAINT ‘ ||constraint_name|| ‘ ‘ as v_sql from user_constraints  where CONSTRAINT_TYPE= ‘R‘ ) loop  DBMS_OUTPUT.PUT_LINE(C.V_SQL);  begin    EXECUTE IMMEDIATE c.v_sql;    exception when others then    dbms_output.put_line(sqlerrm);    end ;  end loop;   for c in ( select ‘ALTER TABLE ‘ ||TNAME|| ‘ DISABLE ALL TRIGGERS ‘ AS v_sql from tab where tabtype= ‘TABLE‘ ) loop    dbms_output.put_line(c.v_sql);    begin    execute immediate c.v_sql;  exception when others then    dbms_output.put_line(sqlerrm);    end ;  end loop;  end ;  /  commit ;

如何查詢Oracle中使用者所有資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.