Reference: blog. csdn. netxiaoxu0123articledetails38846685Reference: Your Reference: blog. csdn. netfycghy0803articledetails16845575ORACLE you can view the current v$ session table
Reference: http://blog.csdn.net/xiaoxu0123/article/details/38846685 Reference: http://blog.sina.com.cn/s/blog_4a80a5730101oxnk.html Reference: In http://blog.csdn.net/fycghy0803/article/details/16845575 ORACLE, you can view
Reference: http://blog.csdn.net/xiaoxu0123/article/details/38846685
Reference: http://blog.sina.com.cn/s/blog_4a80a5730101oxnk.html
Reference: http://blog.csdn.net/fycghy0803/article/details/16845575
In ORACLEV $ sessionTable to view the current valid session information, and can be queried through the SQL _id or SQL _address of v $ sessionV $ SQLView the SQL statements currently being executed;
If you want to view the SQL statements recently executed by the session, you can useV $ active_session_historyThe SQL _id in the table is used to view the recently executed SQL statements. The database liberary is not fresh.
SELECT b.sql_text, --content of SQL a.machine, --which machine run this code a.username, a.module, -- the method to run this SQL c.sofar / totalwork * 100, --conplete percent c.elapsed_seconds, --run time c.time_remaining --remain to run timeFROM v$session a, v$sqlarea b, v$session_longops cWHERE a.sql_hash_value = b.hash_value(+) AND a.SID = c.SID(+) AND a.serial# = c.serial#(+) --AND a.sid=139
The SQL statements recently executed by Oracle:
SELECT sql_text, last_load_timeFROM v$sqlWHERE last_load_time IS NOT NULLORDER BY last_load_time DESC
Others,
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;
Monitor the SQL statement being executed by concurrent
SELECT a.sid, a.serial#, b.sql_text FROM v$session a, v$sqltext bWHERE a.sql_address = b.address --AND a.sid = <...>ORDER BY b.piece
Executing
SELECT a.username, a.sid,b.SQL_TEXT, b.SQL_FULLTEXT FROM v$session a, v$sqlarea b where a.sql_address = b.address
Executed
SELECT b.SQL_TEXT,b.FIRST_LOAD_TIME,b.SQL_FULLTEXTFROM v$sqlarea bWHERE b.FIRST_LOAD_TIME between '2009-10-15/09:24:47' and '2009-10-15/09:24:47' order by b.FIRST_LOAD_TIME
(This method allows you to view the SQL statements executed in a certain period of time, andSQL _FULLTEXTContains the completeSQLStatement)
Others
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
Find the top 10 SQL statements with poor performance
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 ;
View the running sessions that account for a large io
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