oracle監控常用語句

2021-06-28 07:37:57 字數 3803 閱讀 5275

--資料庫例項查詢

select * from gv$version;

--rdbms資訊

select * from gv$version where banner like '%oracle%';

--sql &net版本資訊

select * from gv$version where banner like '%tns%';

--sga資訊(database buffer)

select s.*,round(s.value/1024/1024) from gv$sga s where name = 'database buffers'

--sga(shared pool)

select s.*,round(s.bytes/1024/1024) from gv$sgainfo s where name = 'shared pool size'

--sga(log buffers)

select s.*,round(s.bytes/1024/1024) from gv$sgastat s where s.name='log_buffer'

--db_block size

select p.value/1024,p.* from gv$parameter p where name = 'db_block_size'

--表空間資訊

select * from dba_tablespaces;

--表空間使用率

select f.tablespace_name,

a.total 總共m,

f.free 空閒m,

round((f.free / a.total) * 100) "空閒比率"

from (select tablespace_name, sum(bytes / (1024 * 1024)) total

from dba_data_files

group by tablespace_name) a,

(select tablespace_name, round(sum(bytes / (1024 * 1024))) free

from dba_free_space

group by tablespace_name) f

where a.tablespace_name = f.tablespace_name(+)

order by "空閒比率";

--資料檔案:

select * from dba_data_files;

--控制檔案狀態:

select * from v$controlfile;

select group# as 日誌組,

member 位址,

status 狀態,

is_recovery_dest_file

from v$logfile;

--相關引數檢視(session,processes)

select resource_name,max_utilization,initial_allocation,limit_value from v$resource_limit;

--最大游標(乙個session執行語句數量)

select * from gv$parameter where name like '%cursor%';

--cpu使用率

select round(t1.value*100/(t1.value+t2.value),4)||'%' 使用率,

s.begin_interval_time 開始時間

s.end_interval_time 結束時間

t1.*,t2.*,

from dba_hist_osstat t1,dba_hist_snapshot s,dba_hist_osstat t2

where t1.stat_name = 'busy_ticks'

and t2.stat_name = 'idle_ticks' 

and t1.snap_id = s.snap_id

and t2.snap_id = s.snap_id

and s.begin_interval_time >= to_timestamp('2015-01-19 ', 'yyyy-mm-dd hh24')

and s.begin_interval_time < to_timestamp('2015-01-19 20', 'yyyy-mm-dd hh24');

--最大記憶體

select * from gv$parameter p where name = 'sga_target'

--記憶體使用率

select round(t.bytes*100/1073741824)||'%' 使用率,

to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss') 開始時間,

to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss') 結束時間

from dba_hist_sgastat t,dba_hist_snapshot s

where t.snap_id = s.snap_id

and t.name  = 'free memory'

and t.pool = 'shared pool'

and s.begin_interval_time >= to_timestamp('2015-01-19 08', 'yyyy-mm-dd hh24')

and s.begin_interval_time < to_timestamp('2015-01-19 20', 'yyyy-mm-dd hh24')

order by s.begin_interval_time;

--歷史session 統計

select to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss') 開始時間,

to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss') 結束時間,

count(session_id)

from dba_hist_active_sess_history h,dba_hist_snapshot s

where h.snap_id = s.snap_id

and s.begin_interval_time >= to_timestamp('2015-01-19 08', 'yyyy-mm-dd hh24')

and s.begin_interval_time < to_timestamp('2015-01-19 20', 'yyyy-mm-dd hh24')

and h.session_type = 'foreground'

and h.sql_id is not null

group by  to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss'),to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss')

;--具體執行sql語句查詢

select * from dba_hist_sqltext where sql_id = '';

--無效物件

select owner,object_name,object_type from dba_objects where status!='valid' and owner!='sys' and owner!='system'; 

--io查詢

select * from v$iostat_file;

select * from dba_hist_iostat_filetype;

oracle 常用語句

oracle 產看表空間 select total.name tablespace name free space,total space free space used space,total space from select tablespace name,sum bytes 1024 102...

oracle常用語句

drop tablespace crm online space including contents and datafiles 刪除表空間 drop user wuliu01 cascade 刪除使用者 exp orcl file d dmp 匯出資料庫 imp orcl file e alen...

oracle 常用語句

oracle 常用語句 查詢表的大小 select t.owner,t.segment name,sum t.blocks 8 1024 m as s,t.segment type from dba segments t where t.owner user name group by t.owne...