oracle 查詢最近執行過的 SQL語句

2021-08-13 10:16:08 字數 2010 閱讀 4986

select sql_text,last_load_time from v$sql order by last_load_time desc;

select   sql_text, last_load_time from v$sql where last_load_time is not null and sql_text like 'select%' order by last_load_time desc;

select   sql_text, last_load_time from v$sql where last_load_time is not null and sql_text like 'update%' order by last_load_time desc;

select   sql_text, last_load_time from v$sql where last_load_time is not null and last_load_time like' 14-06-09%' order by last_load_time desc;

---正在執行的

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

oracle 查詢最近執行過的 SQL語句

select sql text,last load time from v sql order by last load time desc select sql text,last load time from v sql where last load time is not null and ...

oracle 查詢最近執行過的 SQL語句

select sql text,last load time from v sql order by last load time desc select sql text,last load time from v sql where last load time is not null and ...

oracle 查詢最近執行過的 SQL語句

select sql text,last load time from v sql order by last load time desc select sql text,last load time from v sql where last load time is not null and ...