When oracle Session is locked, oraclesession
A problem often occurs. A table in oracle cannot be updated suddenly, either through pl/SQL Developer or through sqlplus, the execution of the update statement or the execution of the select * from table_name for update statement is the same and remains in the execution status and cannot be completed. In this case, I guess the session is locked? With this problem, we write an SQL statement:
-- Lock Table query SQL
SELECT object_name, machine, s. sid, s. serial # FROM gv $ locked_object l, dba_objects o, gv $ session s WHERE l. object_id = o. object_id AND l. session_id = s. sid;
The execution result is as follows:
We can see this piece of data. That is to say, a table is locked. At this time, we confirm that, the update operation cannot be completed because the table cannot be updated.
How to release it? Continue to execute an SQL statement:
ALTER system kill session '123 ';
We can see that SID and Serial are queried in the formats of alter system kill session 'sid, serial # '. After the execution is complete:
When the locked session is absent, we will execute the table update operation again. We can see that the update is no problem.