Oracle Series Script 1: Life-saving emergency session processing scripts

Source: Internet
Author: User
Tags chr

background: A deadlock session in the database has soared. The following is expected to quickly locate common locks, rapid intervention processing, and database performance recovery. Long-term operation through the following statements? T more than the database, a.

One, the query out the deadlock SID and other information
SELECT l.session_id Sid,s.serial#,l.locked_mode,l.oracle_username,l.os_user_name,
S.machine,s.terminal,o.object_name,s.logon_time
From V$locked_object L, all_objects O, v$session s
WHERE l.object_id = o.object_id and l.session_id = S.sid
ORDER by Sid, S.serial#;

Second, based on SID location blocking statement
SELECT/+ PUSH_SUBQ /
Command_type, Sql_text, Sharable_mem, Persistent_mem, Runtime_mem, Sorts,version_count, Loaded_Versions, Open_ Versions, Users_opening, executions,users_executing, Loads, First_load_time, Invalidations, Parse_calls,disk_reads, Buffer_gets, rows_processed, Sysdate start_time,
Sysdate finish_time, ' > ' | | Address sql_address, ' N ' Status
From V$sqlarea
where Address = (SELECT sql_address from v$session WHERE Sid =? );

Third, kill the lock
--Kill Lock (Database level-for less urgent situations)
Select ' Alter system kill session ' | | Chr (39) | | t2.sid| | ', ' | | t2.serial#| | Chr (39) | | immediate; '
From V$locked_object t1,v$session T2
where T1.session_id=t2.sid ORDER by t2.logon_time

--Kill Lock (operating system level-for emergency situations)
Select ' Kill-9 ' | | T3.spid
From V$locked_object t1,v$session T2, v$process T3
where t1.session_id=t2.sid and t2.paddr = t3.addr ORDER by T2.logon_time

A daily session query statement is attached:
--All session information
Select from v$session
Select Count (
) from v$session
--session key information
Select username,status,state,machine,logon_time from V$session Order by Username,machine

Oracle Series Script 1: Life-saving emergency session processing scripts

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.