When oracle Session is locked, oraclesession

Source: Internet
Author: User

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.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.