1. 程式人生 > >Oracle資料庫使用者許可權查詢和一些檢視操作(彙總)

Oracle資料庫使用者許可權查詢和一些檢視操作(彙總)

dba許可權:user為有dba許可權的賬號,如sys,system,或者是已經被授予dba許可權

1.查詢使用者擁有的系統許可權
SQL> SELECT GRANTEE,PRIVILEGE FROM DBA_SYS_PRIVS WHERE GRANTEE = 'SCOTT';(dba許可權

2.查詢使用者擁有的物件許可權
SQL> SELECT GRANTEE,TABLE_NAME,PRIVILEGE FROM DBA_TAB_PRIVS WHERE GRANTEE = 'SCOTT';(dba許可權

3.查詢使用者擁有的角色
SQL> SELECT GRANTEE,GRANTED_ROLE FROM DBA_ROLE_PRIVS WHERE GRANTEE ='SCOTT';(dba許可權

4.檢視使用者和預設表空間的關係
select username,default_tablespace from dba_users;(dba許可權
5.Oracle查詢使用者表
select * from user_tables;-->檢視當前使用者能訪問的表 
select * from dba_tables;-->管理員可以看到的資料庫中所有的表(dba許可權
select * from user_all_tables;-->與select * from user_tables;有類似之處不過顯示的鍵值對不一樣。
select * from all_tables;-->顯示使用者有許可權看到的所有的表,包括系統表
6.Oracle查詢使用者檢視
select * from user_views;
7.查詢所有函式和儲存過程:
select * from user_source;
8.查詢所有使用者:
select * from all_users;-->檢視能管理的所有使用者
select * from dba_users;-->檢視資料庫裡面所有使用者(dba許可權


select * from user_users;-- >檢視當前使用者資訊
9.檢視當前使用者連線:
select * from v$Session;(dba許可權
10.檢視使用者角色
SELECT * FROM USER_ROLE_PRIVS;
11.檢視當前使用者許可權:
select * from session_privs;
12.檢視所有使用者所擁有的角色
SELECT * FROM DBA_ROLE_PRIVS;(dba許可權
13.檢視所有角色
select * from dba_roles;(dba許可權
14.檢視資料庫名
SELECT NAME FROM V$DATABASE;(dba許可權

15.檢視所有表空間使用情況
select a.file_id "FileNo",
       a.tablespace_name "Tablespace_name",
       a.bytes "Bytes",
       a.bytes - sum(nvl(b.bytes, 0)) "Used",
       sum(nvl(b.bytes, 0)) "Free",
       sum(nvl(b.bytes, 0)) / a.bytes * 100 "%free"
  from dba_data_files a, dba_free_space b
 where a.file_id = b.file_id(+)
 group by a.tablespace_name, a.file_id, a.bytes
 order by a.tablespace_name;(dba許可權