Get the App
SLTechnology News&Howtos  ›  Database  › 

Only select permission can lock the table? Read and select

Shulou Source: shulou.com Published: 2022-06-01 06:57:21 09月25日 Update

A client asked me why I only have select permission, and I can also lock the table with for update.

I was confused for a moment. I was not sure. I tested it first, as follows:

Create user test11 identified by test11

Create user test12 identified by test12

Grant connect,resource to test11,test12

Create table test11.objects as select * from dba_objects

Grant select on test11.objects to test12

Session 1:

Session 2:

As you can see, it is true that only with readable permissions, you can for update.

Why can for update, it seems illogical, the point is too small, can only be searched on the official documents, have to praise, oracle official documents are really detailed. Can only think of in the official documents to see if there are any clues, a check, found that there is really!

As follows:

SELECT Query the table with the SELECT statement, including SELECT... FOR UPDATE.

As you can see, select does include for update permissions.

The difference is that in addition to select, there is a read to represent the query, but read does not contain for update. This is a change after 12.1.

READ Query the table with the SELECT statement. Does not allow SELECT... FOR UPDATE.

Note: This privilege is available starting with Oracle Database 12 c Release 1 (12.1.0.2).

Why does select have for update permission? it may be out of the hope that queries can enforce consistent relationships.

But in fact, for most query scenarios, for update's table lock permissions are still too large, so starting from 12.1, separate in addition to smaller read permissions to meet customer needs.

Tags: Permissions officials documents queries customers only consistency consistency scenarios for clues or logic requirements changes enforcement testing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple Microsoft Shulou Information NVidia