在PL/SQL中,可以使用以下几种方法来查看被锁的表:
SELECT *
FROM DBA_OBJECTS
WHERE OBJECT_TYPE = 'TABLE'
AND OBJECT_NAME IN (
SELECT OBJECT_NAME
FROM V$LOCKED_OBJECT
);
SELECT OBJECT_NAME, SESSION_ID, ORACLE_USERNAME
FROM V$LOCKED_OBJECT
WHERE OBJECT_TYPE = 'TABLE';
SELECT L.OBJECT_NAME, S.SID, S.SERIAL#
FROM V$LOCK L, V$SESSION S
WHERE L.SID = S.SID
AND L.TYPE = 'TM'
AND L.ID1 = (
SELECT OBJECT_ID
FROM DBA_OBJECTS
WHERE OBJECT_NAME = 'YOUR_TABLE_NAME'
AND OBJECT_TYPE = 'TABLE'
);
以上方法都可以帮助你查看被锁的表,你可以根据实际情况选择使用其中一种方法来查看。