SoFunction
Updated on 2025-04-12

Implementation method of oracle lock table and unlock table

Oracle lock table and unlock table method

The following are the main related tables:

SELECT * FROM v$lock;
SELECT * FROM v$sqlarea;
SELECT * FROM v$session;
SELECT * FROM v$process ;
SELECT * FROM v$locked_object;
SELECT * FROM all_objects;
SELECT * FROM v$session_wait;

View locked table

select ,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;

Check which user and which process cause deadlock

select ,,#,logon_time from v$locked_object a,v$session b where a.session_id =  order by b.logon_time;

View the connection process

SELECT sid, serial#, username, osuser FROM v$session;

Identify the sid of the locked table

serial#,os_user_name, machine_name, terminal, lock type,mode

SELECT , #, , , , , ,
, s.logon_time, 
FROM v$session s, v$lock l
WHERE  = 
AND  IS NOT NULL
ORDER BY sid;

This statement will find the locks generated by all DML statements in the database, and you can also find

Any DML statement actually produces two locks, one is a table lock and the other is a row lock.

– Kill the process ‘sid,serial#’

alter system kill session'210,11562';

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.