该博文同时分享在http://topic.youkuaiyun.com/u/20090930/16/9dbdeab0-4670-4fa0-b6b4-45ca725281dd.html.
我综合oracle技术中国用户讨论组的一些知识,及自己掌握的一些知识,
把DBA人员应该掌握的一些SQL语句罗列了下,希望能对大家有所帮助。
下面罗列的这些SQL语句,我想,对于DBA人员来说是应该掌握的。
3.其他方面
①根据实例来查看进程id。
select spid
from v$process
where addr in (select paddr from v$session where sid = $sid)
②根据进程id来查看实例。
select sid
from v$session
where paddr in (select addr from v$process where spid = $pid)
③查看当前在session中的sql文。
select SQL_TEXT
from V$SQLTEXT
where HASH_VALUE = (select SQL_HASH_VALUE from v$session where sid = &sid)
order by PIECE
④查看v$session_wait。
select *
from v$session_wait
where event not like 'rdbms%'
and event not like 'SQL*N%'
and event not like '%timer';
⑤Dictionary缓存的命中率。
/*It should be about 15%, otherwise add share_pool_size*/
SELECT sum(getmisses) / sum(gets) FROM v$rowcache;
⑥利用文件号和数据块来查看DB中的各个对象。
select owner,segment_name,segment_type
from dba_extents
where file_id = [$fno and &dno between block_id and block_id + blocks - 1 ]
⑦寻找hot block。
select /*+ ordered */
e.owner || '.' || e.segment_name segment_name,
e.extent_id extent#,
x.dbablk - e.block_id + 1 block#,
x.tch,
l.child#
from sys.v$latch_children l, sys.x$bh x, sys.dba_extents e
where l.name = 'cache buffers chains'
and l.sleeps > &sleep_count
and x.hladdr = l.addr
and e.file_id = x.file#
and x.dbablk between e.block_id and e.block_id + e.blocks - 1;
⑧找出每个文件上的等待事件。
select df.name, kf.count
from v$datafile df, x$kcbfwait kf
where (kf.indx + 1) = df.file#;
⑨找出引起等待事件的SQL语句。
select sql_text, c.event
from v$sqlarea a, v$session b, v$session_wait c
where a.address = b.sql_address
and b.sid = c.sid;
⑩判断你是从pfile启动还是spfile启动。
SQL> select decode(count(*), 1, 'spfile', 'pfile' ) as DECODE
2 from v$spparameter
3 where rownum=1
4 and isspecified='TRUE';
DECODE
------
spfile