oracle-查询锁表sql

查看哪个表被锁

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

查看是哪个session引起的锁表

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

杀掉进程

alter system kill session 'sid,serial#';

查询当前正在执行的sql

 SELECT
	a.program,
	b.spid,
	a.SID,
	a.SERIAL#,
	c.sql_text,
	c.SQL_ID,
	a.USERNAME,
	c.DISK_READS,
	c.BUFFER_GETS,
	c.EXECUTIONS
FROM
	v$session a,
	v$process b,
	v$sqlarea c
WHERE
	a.paddr = b.addr
	AND a.sql_hash_value = c.hash_value
	AND a.username IS NOT NULL;

查询当前执行存储过程

SELECT
	name,
	locks,
	pins
FROM
	v$db_object_cache
WHERE
	locks > 0
	AND pins > 0
	AND TYPE = 'PROCEDURE';

 

posted @ 2023-11-15 09:41  许孟  阅读(384)  评论(0编辑  收藏  举报