Oracle運維常用SQL

2021-10-04 18:15:10 字數 3012 閱讀 7209

oracle處理資料緩慢,系統相應緩慢,除了排查**、網路,資料庫也不可忽視,下面一些語句可以篩查需要進行調優的sql、oracle設定等。

select *

from (select sa.sql_text,

sa.sql_fulltext,

sa.executions "執行次數",

round(sa.elapsed_time / 1000000, 2) "總執行時間",

round(sa.elapsed_time / 1000000 / sa.executions, 2) "平均執行時間",

sa.command_type,

sa.parsing_user_id "使用者id",

u.username "使用者名稱",

s.executions "執行次數",

s.parsing_user_id "使用者名稱",

rank() over(order by executions desc) exec_rank

from v$sql s

left join all_users u

on u.user_id = s.parsing_user_id) t

where exec_rank <= 100;

select table_name,total_phys_io

from ( select owner||'.'||object_name as table_name,

sum(value) as total_phys_io

from v$segment_statistics

where owner!='sys' and object_type='table'

and statistic_name in ('physical reads','physical reads direct',

'physical writes','physical writes direct')

group by owner||'.'||object_name

order by total_phys_io desc)

where rownum <=10;

select *

from (select v.sql_id,

v.child_number,

v.sql_text,

v.elapsed_time,

v.cpu_time,

v.disk_reads,

rank() over(order by v.elapsed_time desc) elapsed_rank

from v$sql v) a

where elapsed_rank <= 10;

select *

from (select v.sql_id,

v.child_number,

v.sql_text,

v.elapsed_time,

v.cpu_time,

v.disk_reads,

rank() over(order by v.cpu_time desc) elapsed_rank

from v$sql v) a

where elapsed_rank <= 10;

select *

from (select v.sql_id,

v.child_number,

v.sql_text,

v.elapsed_time,

v.cpu_time,

v.disk_reads,

rank() over(order by v.disk_reads desc) elapsed_rank

from v$sql v) a

where elapsed_rank <= 10;

1.查詢被鎖的表:

select b.owner,b.object_name,a.session_id,a.locked_mode

from v$locked_object a,dba_objects b

where b.object_id = a.object_id

2.查詢鎖表的程序

select b.username,b.sid,b.serial#,logon_time

from v$locked_object a,v$session b

where a.session_id = b.sid order by b.logon_time

3.kill程序

alter system kill session 'sid,serial#';

4.原被鎖的oracle使用者提示「已斷開連線,請重新登入",解鎖完成。

記錄部分常用sql,持續更新。希望對各位讀者有所幫助。

Infor XA ERP運維常用SQL

記錄infor xa erp工作用sql 1 綠屏shipment操作不正常退出,造成shipment狀態異常,無法繼續任何操作 解鎖sql 綠屏異常退出,shipment異常 update 環境庫.mbadres0 set adiist 50 where adiist 99 and adhfcd ...

mysql常用運維 (MYSQL常用運維指令)

1 mysql執行狀態 service mysqld status service mysqld start service mysqld stop 2 檢視sql程序,清理sql程序 show full processlist kill 2920578 3 賬號建立 資料庫授權 4 密碼修改 my...

oracle日常運維

1.解鎖使用者 select username,account status from dba users b where b.username upper alter user account unlock 解鎖 alter user identified by sh 解開expired alte...