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

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

WBOY
Release: 2022-01-25 11:47:27
Original
24003 people have browsed it

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;
Copy after login

--View the lock table process SQL statement 2:

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

--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#;
Copy after login

--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';
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template