- 数据库维护
-
1、当前数据库各个终端连接数
SELECT "连接数","终端名称"
FROM ( SELECT COUNT(TERMINAL) AS 连接数,
TERMINAL AS 终端名称
FROM v$sessionGROUP BY TERMINAL
)
ORDER BY 连接数 DESC;
2、查询性能最差的SQL
SELECTdisk_reads,executions,rows_processed,
first_load_time,sql_text
FROMsys.v_$sqlarea
WHEREdisk_reads >10
AND executions < 10
ORDER BYfirst_load_time;
3、找使用CPU多的用户session
SELECT a.sid,spid,status,substr(a.program,1,40) prog,
a.terminal,osuser,value/60/100 value
FROM v$session a,v$process b,v$sesstat c
WHERE c.statistic#=12
AND c.sid=a.sid
AND a.paddr=b.addr
ORDER BY VALUE DESC;
4、当前各用户运行什么SQL语句
SELECTosuser, username, sql_text
FROMv$session a, v$sqltext b
WHEREa.sql_address =b.address
ORDER BY address, piece;