标签:ber sql语句 between bms not execution des ast user
--查询正在执行的SQL语句
select a.program, b.spid, c.sql_text,c.SQL_FULLTEXT,c.SQL_ID
from v$session a, v$process b, v$sqlarea c
where a.paddr = b.addr
and a.sql_hash_value = c.hash_value
and a.username is not null;
---查询执行过的SQL语句
select b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXT
from v$sqlarea b
where b.FIRST_LOAD_TIME between ‘2009-10-15/09:24:47‘ and
‘2009-10-15/09:24:47‘ order by b.FIRST_LOAD_TIME
(此方法好处可以查看某一时间段执行过的sql,并且 SQL_FULLTEXT 包含了完整的 sql 语句)
--查询比较耗CPU的SQL语句
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;
--查询比较耗磁盘的SQL语句
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;
--查询比较慢的SQL语句
select * from (
select parsing_user_id,executions,sorts
command_type,disk_reads,sql_text from v$sqlarea order by disk_reads desc
)where rownum<10
--Oracle 对未提交事务的查询
select a.sid,a.blocking_session,a.last_call_et,a.event,
object_name,
dbms_rowid.rowid_create(1,data_object_id,rfile#,ROW_WAIT_BLOCK#,ROW_WAIT_ROW#) "rowid" ,
c.sql_text,c.sql_fulltext
from v$session a,v$sqlarea c ,dba_objects,v$datafile
where a.blocking_session is not null
and a.sql_hash_value = c.hash_value
and ROW_WAIT_OBJ#=object_id and file#=ROW_WAIT_FILE#;
标签:ber sql语句 between bms not execution des ast user
原文地址:http://www.cnblogs.com/ruqinzhe/p/7591481.html