在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'
);
以上方法都可以幫助你查看被鎖的表,你可以根據實際情況選擇使用其中一種方法來查看。