Oracle SQL statements

Source: Internet
Author: User

Monitoring scripts executed by Oracle SQL statements! [@[email protected]]

--Find the method for bad sql:
SELECT * FROM (select Buffer_gets, Sql_text
From V$sqlarea
where Buffer_gets >500000
ORDER BY buffer_gets Desc) where rownum<=30;


--Perform the number of times SQL

Select Sql_text,executions from
(select Sql_text,executions from V$sqlarea ORDER BY executions Desc)
where rownum<81;


--Read more about the SQL of magnetic plates

Select Sql_text,disk_reads from
(select Sql_text,disk_reads from V$sqlarea ORDER BY disk_reads Desc)
where rownum<21;


--Sort multiple SQL

Select Sql_text,sorts from
(select Sql_text,sorts from V$sqlarea order by sorts Desc)
where rownum<21;


--Analysis of the number of times too much, too little to perform, to use kidnapped fixed kidnapped to write SQL

Set pagesize 600;
Set Linesize 120;
Select substr (sql_text,1,80) "SQL", count (*), SUM (executions) "Totexecs"
From V$sqlarea
where executions < 5
Group by substr (sql_text,1,80)
Having count (*) > 30
Order by 2;


--the observation of the target

Set pages 300;
Select SUM (a.value), b.name
From V$sesstat A, v$statname b
where a.statistic# = b.statistic#
and B.name = ' opened Cursors current '
Group BY B.name;
Select COUNT (0) from V$open_cursor;
Select User_name,sql_text,count (0) from V$open_cursor
GROUP BY User_name,sql_text have count (0) >30;


--View the SQL that was run by the previous user
Select Sql_text from V$sqltext_with_newlines where (hash_value,address) in
(select Sql_hash_value,sql_address from v$session where username= ' &username ')
Order BY Address,piece;

Oracle SQL statements

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.