SQL Server queries locked tables and locks table
--1. View Locked TableSELECTrequest_session_id asspidobject_name(resource_associated_entity_id) asTableName fromSys.dm_tran_locksWHEREResource_type='OBJECT' --SPID lock table process; tableName Locked table name--2. UnlockingDeclare @spid int Set @spid =The process number of the locked tableDeclare @sql varchar( +)Set @sql='Kill'+cast(@spid as varchar)exec(@sql)
Oracle queries locked tables and locks table
--1. The code for the Lock table query is in the following form:SELECT Count(*) fromV$locked_object;SELECT * fromV$locked_object;--2. See which table is lockedSELECTB.owner,b.object_name, A.session_id,a.locked_mode fromV$locked_object A,dba_objects bWHEREB.object_id =A.object_id; --3. See which session is causing theSELECTB.username,b.sid,b.serial#,logon_time fromV$locked_object A,v$session bWHEREa.session_id=B.sidOrder byB.logon_time; --4. Kill the corresponding processAlterSystemKillSession'1025,41'; --1025 of them are sid,41 for serial#.
"SQL Server" lock table and unlock operations for various databases