Oracle checks the locked table and the locked process, and kills the process. oracle

Source: Internet
Author: User

Oracle checks the locked table and the locked process, and kills the process. oracle

-- 1. view the locked table

SELECT p.spid, a.serial#, c.object_name, b.session_id, b.oracle_username,b.os_user_nameFROM v$process p, v$session a, v$locked_object b, all_objects cWHERE p.addr = a.paddrAND a.process = b.processAND c.object_id = b.object_id

-- 2. view the process lock

SELECT sid, serial#, username, status, osuser FROM v$session where serial# = '5002'SELECT sid, serial#, username, status, osuser FROM v$session where serial# = '3789'

-- 3. Kill this process

alter system kill session 'sid,serial#';alter system kill session '269,3789';alter system kill session '34,4661';alter system kill session '265,5002';alter system kill session '289,1688';alter system kill session '282,5799';

After checking whether oracle locks the table, if I do not have the DBA permission, how can I kill the process or unlock the table?

First:
SQL> select session_id from v $ locked_object;
49
SQL> SELECT sid, serial #, username FROM v $ session where sid = 49;
554 system
SQL> ALTER SYSTEM KILL SESSION '123 ';
Second:
If you use a client to log on, You can directly turn off the client, because your client is also a session
Normal users can also, because you are the user to start this process, you can also close this process

The records in the oracle table are locked by a user and cannot be found in the process of the table. Is there a way to solve this problem?

Use dba_objects to find the object_id of the table, and then check that id1 in v $ lock is equal to object_id. In this row, a user with a different SID must have a lock for this table, it certainly does not have a commit in the update table for a long time. either find the client to make it commit or rollback, or kill it through sid.
There are several methods below
A. $ ORACLE_HOME/rdbms/admin/utllockt. SQL is easy to use!
B. select blocking_session from v $ session where blocking_session not is null. You can find out who will block the session in 10 Gb.
C. dba_waiters can query the blocking source and target
D. dba_blockers only has one column of blocking sources

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.