一、登录oracle数据库
方法一:
1、登录oracle用户
2、执行命令 sqlplus /nolog
3、链接数据库
SQL> conn sys/ as sysdba;
Enter password:
Connected.
方法二:
1、登录oracle用户
2、链接数据库:
SQL> sqlplus 用户名/密码 as sysdba;
二、查看被锁的表
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 where ao.object_id=lo.object_id and lo.session_id=sess.sid;
三、查看导致锁表的SQL
select a.username username, a.sid sid, a.serial# serial,b.id1 id1, c.sql_text sqltext from v$session a, v$lock b, v$sqltext c where b.id1 in (select distinct e.id1 from v$session d, v$lock e where d.lockwait = e.kaddr) and a.sid = b.sid and c.hash_value = a.sql_hash_value and b.request = 0;
四、解锁被锁的表
alter system kill session 'sess.sid,sess.serial#';
alter system kill session '1,1118';