Oracle 关闭session脚本,用于处理表数据被锁定问题
【oracle查看被锁的表和解锁 https://www.cnblogs.com/XQiu/p/5212787.html】
--1
SELECT * FROM V$DB_OBJECT_CACHE WHERE name='TYWDM_YZYWLB' AND LOCKS!='0';
--2
select wm_concat(SID) from V$ACCESS WHERE object='TYWDM_YZYWLB';
--3
SELECT SID||','||SERIAL# AS sessionID,SID,SERIAL#,PADDR FROM V$SESSION WHERE SID IN (1,73,145,298,362,1429,1569,1707,1787,1918,1931,2073,2136);
---4
SELECT 'alter system kill session ''' ||SID||','||SERIAL# || ''' immediate;' AS str
FROM V$SESSION WHERE SID IN (1,73,145,298,362,1429,1569,1707,1787,1918,1931,2073,2136);
---5
alter system kill session '1,34169' immediate;
alter system kill session '73,15131' immediate;
alter system kill session '362,44555' immediate;
alter system kill session '1787,46701' immediate;
alter system kill session '1918,48825' immediate;
alter system kill session '1931,52143' immediate;
alter system kill session '2073,4181' immediate;