oracle不常用的查詢語句

2021-08-31 10:58:59 字數 2734 閱讀 3284

1.檢視所有使用者:select * from dba_user(all_users,user_users);

2.檢視使用者系統許可權:select * from dba_sys_privs(all_sys_privs,user_sys_privs);

3.檢視使用者物件許可權:select * from dba_tab_privs(all_tab_privs,user_tab_privs);

4.檢視所有角色:select * from dba_roles;

5.檢視使用者所擁有的角色:select * from dba_role_privs(user_role_privs);

6.查詢oracle中所有使用者資訊:select * from dba_user;

7.只查詢使用者和密碼:select username,password from dba_users;

8.查詢當前使用者資訊:select * from dba_ustats;

9.查詢使用者可以訪問的視**本:select * from dba_varrays;

10.查詢資料庫中所有檢視的文字:select * from dba_views;

11.查詢全部索引:select * from user_indexes;

12.查詢全部**:select * from user_tables;

13.查詢全部約束:select * from user_constraints;

14.查詢全部物件:select * from user_objects;

15.檢視相關程序在資料庫中的會話

select a.sid,a.serial#,a.program, a.status,

substr(a.machine,1,20), a.terminal,b.spid

from v$session a, v$process b

where a.paddr=b.addr

and b.spid = &spid;

16.檢視資料庫中被鎖住的物件和相關會話

select a.sid,a.serial#,a.username,a.program,

c.owner, c.object_name

from v$session a, v$locked_object b, all_objects c

where a.sid=b.session_id and

c.object_id = b.object_id;

17.檢視相關會話正在執行的sql

select sql_text from v$sqlarea where address =

( select sql_address from v$session where sid = &sid );

18.檢視消耗資源最多的sql

select hash_value, executions, buffer_gets, disk_reads, parse_calls

from v$sqlarea

where buffer_gets > 10000000or disk_reads > 1000000

orderby buffer_gets + 100 * disk_reads desc;

19.檢視某條sql語句的資源消耗:

select hash_value, buffer_gets, disk_reads, executions, parse_calls

from v$sqlarea

where hash_value = 228801498and address = hextoraw('cbd8e4b0');

20.查詢sql語句的動態執行計畫:

首先使用下面的語句找到語句的在執行計畫中的address和hash_code

select sql_text, address, hash_value from v$sql t where (sql_text like '%function_t(表名大寫!)%')

然後:

select operation, options, object_name, cost from v$sql_plan

where address = 'c00000016bd6d248' and hash_value = 664376056;

21.查詢oracle的版本:

select * from v$version;

22.查詢資料庫的一些引數:

select * from v$parameter

23.查詢你的session資訊

select sid, osuser, username, machine, process

from v$session where audsid = userenv('sessionid');

24.當machine已知的情況下查詢session

select sid, osuser, username, machine, terminal

from v$session

where terminal = 'pts/tl' and machine = 'rgmdbs1';

25.查詢當前被某個指定session正在執行的sql語句。假設sessionid為100

select b.sql_text

from v$session a,v$sqlarea b

where a.sql_hashvalue=b.hash_value and a.sid=100

oracle常用查詢語句

1 檢視oracle表空間的使用情況直接使用情況 2 檢視oracle連線數 select count from v session 連線數 select count from v session where status active 併發連線數 alter system set processe...

Oracle(三)常用的查詢語句

oracle下的三個檢視 dba tables 擁有dba角色的使用者可以檢視系統中的所有表 user tables 登入資料庫的當前使用者擁有的所有表 all tables 登入資料庫的當前使用者有許可權檢視的所有表 簡單應用 select table name from user tables ...

不常用到的sql語句記錄

1 查詢觸發器是否存在 oracle select count as count from user triggers where trigger name upper triname sqlserver select count as count from sysobjects where nam...