Query and unlock lock tables in oracle

Source: Internet
Author: User


If a lock wait occurs when querying the lock table in oracle and unlocking the table, we may want to know who has locked the table and who has waited. The following statement can be used to query who has locked the table: www.2cto.com SELECT/* + rule */s. username, decode (l. type, 'TT', 'table lock', 'tx ', 'row lock', NULL) LOCK_LEVEL, o. owner, o. object_name, o. object_type, s. sid, s. serial #, s. terminal, s. machine, s. program, s. osuser FROM v $ session s, v $ lock l, dba_objects o WHERE l. sid = s. sid AND l. id1 = o. object_id (+) AND s. the statement below username is not null can query who is waiting: SELECT/* + rule */lpad ('', decode (l. xidusn, 0, 3, 0) | l. oracle_username User_name, o. owner, o. object_name, o. object_type, s. sid, s. serial # FROM v $ locked_object l, dba_objects o, v $ session s WHERE l. object_id = o. object_id AND l. session_id = s. sid order by o. object_id, xidusn desc unlock command: alter system kill session 'sid, serial #'

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.