Oracle for update row locks

Source: Internet
Author: User

SELECT ... The syntax for the FOR UPDATE statement is as follows:
SELECT ... For UPDATE [of Column_list][wait n| Nowait][skip LOCKED];

which
The of clause is used to specify the column that is about to be updated, that is, the row of the related table that locks a particular column.
The wait clause specifies the number of seconds to wait for another user to release the lock, preventing an indefinite wait.

The advantages of using the FOR UPDATE WAIT clause are as follows:
1. Prevent indefinitely waiting for a locked line;
2. Allow more control of the lock waiting time in the application;
3. Very useful for interactive applications, as these users cannot wait for uncertainty;
4. If skip locked is used, the locked row can be crossed and the ' resource busy ' exception report raised by Wait n is not reported.

Attention:
1.for update nowait and for update will lock the result set that is being queried, unlike if another thread is modifying the data in the result set, the for update nowait does not wait for the resource, as long as it finds that some data in the result set is locked. Immediately returns the "ORA-00054 error, content is that the resource is busy, but specifies to get the resource in NOWAIT way."
The 2.OF clause, when implicated in multiple tables, has a greater effect, such as not using the column of the specified locked table, all related rows of the table are locked, and if the column to be modified is specified in the, only the rows of the tables associated with those columns will be locked.

Oracle for update row locks

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.