Home > Database > Oracle > body text

Reasons why Oracle locks the table

hzc
Release: 2020-06-09 13:27:11
Original
4071 people have browsed it

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

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

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

2. ORACLE unlocking method

alter system kill session 'sid,serial#';
Copy after login

spid Locked process number

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!