---正在執行的
select a.username, a.sid,b.sql_text, b.sql_fulltext
from v$session a, v$sqlarea b
where a.sql_address = b.address
---執行過的
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 語句)
其他select osuser,program,username,schemaname,b.cpu_time,status,b.sql_text
from v$session a left join v$sql b on a.sql_address=b.address and a.sql_hash_value=b.hash_value order by b.cpu_time desc
select address, sql_text, piece
from v$session, v$sqltext
where address = sql_address
-- and machine = < you machine name >
order by address, piece
查詢前十條效能差的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 ;
檢視佔io較大的正在執行的session
select se.sid,se.serial#,pr.spid,se.username,se.status,
se.terminal,se.program,se.module,、se.sql_address,st.event,st.
p1text,si.physical_reads,
si.block_changes from v$session se,v$session_wait st,
v$sess_io si,v$process pr where st.sid=se.sid and st.
sid=si.sid and se.paddr=pr.addr and se.sid>6 and st.
wait_time=0 and st.event not like '%sql%' order by physical_reads desc
select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.sid,t2.logon_time;
select sql_text from v$session a,v$sqltext_with_newlines b
where decode(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value
and a.sid=112 order by piece
alter system kill session'107,38471'
查詢Oracle正在執行和執行過的SQL語句
正在執行的sql select a.username,a.sid,b.sql text,b.sql fulltext from v session a,v sqlarea b where a.sql address b.address 執行過的sql select b.sql text,b.firs...
查詢Oracle正在執行和執行過的SQL語句
正在執行的 selecta.username,a.sid,b.sql text,b.sql fulltext fromv session a,v sqlarea b wherea.sql address b.address 執行過的 selectb.sql text,b.first load tim...
查詢Oracle正在執行和執行過的SQL語句
正在執行的 select a.username,a.sid,b.sql text,b.sql fulltext from v session a,v sqlarea b where a.sql address b.address 執行過的 select b.sql text,b.first load...