Home > Database > Mysql Tutorial > Introduction to Oracle's method of viewing locked tables and unlocking them (code example)

Introduction to Oracle's method of viewing locked tables and unlocking them (code example)

不言
Release: 2019-02-12 11:47:06
forward
3101 people have browsed it

This article brings you an introduction to Oracle's method of viewing locked tables and unlocking them (code examples). It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. .

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

--View the locked tables

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

--Check which user and process are deadlocked

select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
Copy after login

--Check the connected process

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

--3. Find out the sid, serial#,os_user_name, machine_name, terminal of the locked table, the lock type, mode

SELECT s.sid, s.serial#, s.username, s.schemaname, s.osuser, s.process, s.machine,
s.terminal, s.logon_time, l.type
FROM v$session s, v$lock l
WHERE s.sid = l.sid
AND s.username IS NOT NULL
ORDER BY sid;
Copy after login

This statement will find the locks generated by all DML statements in the database, and also It can be found that
Any DML statement actually generates 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'; There must be spaces when connecting here, otherwise an error will be reported, for example(alter system kill session'210,11562';).

The above is the detailed content of Introduction to Oracle's method of viewing locked tables and unlocking them (code example). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
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