What is the difference between for update and for update?

Source: Internet
Author: User
1

Select * From ttable1 for update

Lock all rows in the Table. Only read and write operations are allowed.

2

Select * From ttable1 where pkid = 1 for update

Only lock the row with pkid = 1

3

Select * From Table1 a join Table2 B on A. pkid = B. pkid for update

Lock all records of two tables

This statement locks all records of the two tables that match the ID, instead of locking all records of the two tables. Correct the statements.
 
This statement locks all records of the two tables that match the ID, instead of locking all records of the two tables. Correct the statements.
 
This statement locks all records of the two tables that match the ID, instead of locking all records of the two tables. Correct the statements.
 
(This statement locks all records of the two tables that meet the ID matching condition, instead of locking all records of the two tables. Correct the statements)

4

Select * From Table1 a join Table2 B on A. pkid = B. pkid where a. pkid = 10 for update

Lock the rows in the two tables that meet the conditions

5.

Select * From Table1 a join Table2 B on A. pkid = B. pkid where a. pkid = 10 for update of A. pkid

Only lock rows in Table 1 that meet the conditions

Note: For update of is incorrect. OracleIt is used to lock fields.

Http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10826/pco03dbc.htm#i4233

Restrictions

You cannot use for update with multiple tables, but you must use for update of toidentify a column in the table that you want locked. row locks obtained by a for update statement are cleared by a commit, which explains why
The cursor is closed for you. If you try to fetch from a for update cursor after a commit, Oracle generates a fetch out of sequence error.

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.