全栈博客园 全栈博客园全栈博客园

oracle检查锁表

1. 检查当时会话持有的锁:

```sqlSELECT s.sid, s.serial, s.username, s.osuser, s.machine, s.program, s.lockwait, l.locked_modeFROM v$session s, v$locked_object lWHERE s.sid = l.session_id;```

2. 检查当时数据库中所有锁的信息:

```sqlSELECT s.sid, s.serial, s.username, s.osuser, s.machine, s.program, s.lockwait, l.locked_mode, o.object_name, o.object_typeFROM v$session s, v$locked_object l, dba_objects oWHERE s.sid = l.session_idAND l.object_id = o.object_id;```

3. 检查当时数据库中所有等候锁的会话:

```sqlSELECT s.sid, s.serial, s.username, s.osuser, s.machine, s.program, s.lockwait, l.requestFROM v$session s, v$lock lWHERE s.sid = l.sidAND l.lmode = 0;```

4. 检查当时数据库中所有等候锁的目标:

```sqlSELECT o.object_name, o.object_type, l.request, s.sid, s.serial, s.username, s.osuser, s.machine, s.programFROM v$lock l, v$session s, dba_objects oWHERE l.id1 = o.object_idAND l.sid = s.sidAND l.lmode = 0;```

这些查询句子能够协助你了解当时数据库中锁表的状况,包含哪些会话持有锁、哪些会话正在等候锁、锁的类型以及锁的目标等信息。你能够根据需要挑选适宜的查询句子来获取所需的信息。

未经允许不得转载:全栈博客园 » oracle检查锁表