Summary of SQL statements recently executed in Oracle query

Source: Internet
Author: User

I. Query recently executed SQL statements
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;
2. Ongoing
Select a. username, a. sid, B. SQL _TEXT, B. SQL _FULLTEXT
From v $ session a, v $ sqlarea B
Where a. SQL _address = B. address
III. Executed
Select B. SQL _TEXT, B. FIRST_LOAD_TIME, B. SQL _FULLTEXT
From v $ sqlarea B
Where B. FIRST_LOAD_TIME between '2017-10-2009: 24: 47 'and
'2017-10-2009: 24: 47 'order by B. FIRST_LOAD_TIME
(This method allows you to view the SQL statements executed in a certain period of time, and SQL _FULLTEXT contains the complete SQL statement)
4. Search for 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;
5. 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
VI. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.