日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

查询oracle中所有用户信息

發(fā)布時間:2025/7/14 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 查询oracle中所有用户信息 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.查看所有用戶:
select * from dba_users;??
select * from all_users;??
select * from user_users;

2.查看用戶或角色系統(tǒng)權(quán)限(直接賦值給用戶或角色的系統(tǒng)權(quán)限):
select * from dba_sys_privs;??
select * from user_sys_privs; (查看當(dāng)前用戶所擁有的權(quán)限)

3.查看角色(只能查看登陸用戶擁有的角色)所包含的權(quán)限
sql>select * from role_sys_privs;

4.查看用戶對象權(quán)限:
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系統(tǒng)權(quán)限(查詢時需要相應(yīng)權(quán)限)
select * from V$PWFILE_USERS

8.SqlPlus中查看一個用戶所擁有權(quán)限
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、獲取當(dāng)前用戶下所有的表:select table_name from user_tables;

12、刪除某用戶下所有的表數(shù)據(jù): select 'truncate table? ' || table_name from user_tables;

13、禁止外鍵
ORACLE數(shù)據(jù)庫中的外鍵約束名都在表user_constraints中可以查到。其中constraint_type='R'表示是外鍵約束。
啟用外鍵約束的命令為:alter table table_name enable constraint constraint_name
禁用外鍵約束的命令為:alter table table_name disable constraint constraint_name
然后再用SQL查出數(shù)據(jù)庫中所以外鍵的約束名:
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禁用/啟用外鍵和觸發(fā)器
--啟用腳本
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;

?

轉(zhuǎn)自:http://jiqinlin.iteye.com/blog/758469

轉(zhuǎn)載于:https://www.cnblogs.com/yilinzi/p/7130936.html

總結(jié)

以上是生活随笔為你收集整理的查询oracle中所有用户信息的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。