Home  >  Article  >  Database  >  Reasons why Oracle locks the table

Reasons why Oracle locks the table

hzc
hzcOriginal
2020-06-09 13:27:114151browse

Reasons why Oracle locks the table

The reason why oracle locks the table:

1. Check the lock table situation in the current system in ORACLE

select * from v$locked_object

You can pass Query

v$locked_object to get sid and objectid,

and then use sid and v$session chainTable query is where the table is locked,

uses the objectid field in v$session and the of dba_objects id field association,

query detailed lock table status.

Query the SQL as follows:

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, v$process p 
where ao.object_id = lo.object_id and lo.session_id = sess.sid;

Query what SQL caused the lock table, the SQL is as follows:

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#;

2. ORACLE unlocking method

alter system kill session 'sid,serial#';

spid Locked process number

serial# v$session 这个视图中取出来的

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of Reasons why Oracle locks the 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
Previous article:How to install oracleNext article:How to install oracle