Home  >  Article  >  Database  >  What is the statement for Oracle to query the lock table?

What is the statement for Oracle to query the lock table?

WBOY
WBOYOriginal
2022-01-25 11:47:2723975browse

In Oracle, you can use the select statement to query the statement that causes the table to be locked. This statement is used to perform simple queries on table data. The syntax is "select*from v$session t1,v$locked_object t2 where t1.sid= t2.SESSION_ID".

What is the statement for Oracle to query the lock table?

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

What is the statement of oracle querying the lock table?

--View the lock table process SQL statement 1:

--The locked object table, database object table, data session table Association to obtain the session corresponding to the locked object;

select sess.sid, 
sess.serial#, 
lo.oracle_username, 
lo.os_user_name, 
ao.object_name, 
lo.locked_mode 
from v$locked_object lo, 
dba_objects ao, 
v$session sess 
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

--View the lock table process SQL statement 2:

select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;

--View the SQL statement that caused the lock table to be

select l.session_id sid, 
s.serial#, 
l.locked_mode, 
l.oracle_username, 
s.user#, 
l.os_user_name, 
s.machine, 
s.terminal, 
a.sql_text, 
a.action 
from v$sqlarea a, v$session s, v$locked_object l 
where l.session_id = s.sid 
and s.prev_sql_addr = a.address 
order by sid, s.serial#;

--Kill the lock table process:

--Get the SID and serial# through the above query, replace the following x, y, you can unlock the locked state

alter system kill session 'x,y';

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of What is the statement for Oracle to query the lock table?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn