Quick Oracle Data lock Removal

Source: Internet
Author: User

There are many articles such as Oracle Data lock quick detection and removal on the Internet. I hope to quickly find all row-level locks in a table and remove them together. So I improved it: if you want to use the kill-9 sessionPid method, the view V $ PROCESS will be used, but the query speed is very slow. You can create a table first: SQL code/* create table session_process_table nologging as select * from V $ PROCESS D where 1 = 0; */truncate table session_process_table; insert into session_process_table select * from V $ process d; commit; -- view the data lock select d. SPID, -- operating system process number. sid, B. serial #, decode (. type, 'Mr ', 'mediareco-very', 'rt', 'redothread', 'UN ', 'username', 'tx', 'Transaction', 'TT ', 'dml', 'ul ', 'pl/sqluserlock', 'dx', 'distribute DXaction ', 'cf', 'controlfile', 'is ', 'instancestate', 'fs', 'fileset',-'ir', 'instancecovery', 'st ', 'diskspacetransaction', 'ts', 'tempsegment ', 'iv', 'librarycacheinvalida-tion ', 'Ls', 'logstartorswitch', 'rw', 'rowwait ', 'sq ', 'sequencenumber', 'te', 'extendtable', 'TT', 'temptable', 'unknown') LockType, c. object_name, B. username, decode (. lmode, 0, 'none', 1, 'null', 2, 'row-S', 3, 'row-x', 4, 'share', 5, 's/Row-x', 6, 'exclusi Ve ', 'unknown') LockMode, B. LOGON_TIME, B. MACHINE, B. PADDR from v $ lock a, all_objects c, v $ session B, session_process_table D where 1 = 1 and d. ADDR = B. PADDR and. sid = B. sid and. type in ('TT', 'tx ') and. id1 = c. object_id and c. object_name = 'locked _ table '; -- shell-kill-9 the SQL statement above spid can find the OS process Number of the session to which the data lock belongs within 2 seconds. LOCKED_TABLE indicates the name of the table where the lock to be queried is located. This method is used on the Internet: alter system kill session 'sid, serial # '. I don't think it is suitable for me. It takes too long. If you only want to kill an important lock, you can. Attached the owner SQL for data query, which may be useful to some users: SQL code -- select command_type, SQL _text, sharable_mem, persistent_mem, runtime_mem, sorts, version_count, loaded_versions, open_versions, users_opening, executions, users_executing, loads, metrics, invalidations, metrics, disk_reads, metrics, rows_processed, sysdate start_time, sysdate finish_time, address SQL _address, 'n' status from v $ sqlarea where Ddress = (select SQL _address from v $ session where sid = $ sid); -- $ sid is the. sid of the last SQL query. I used the preceding SQL statement in oracle9.

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.