1z0-062 题库解析3

题目:
The hr user executes the following query on the employees table but does not issue commit, rollback, or any data definition language (DDL) command after that:

SQL> SELECT job

FROM employees

WHERE job='CLERK' FOR UPDATE OF empno;

HR then opens a second session.

Which two operations wait when executed in HR's second session?

A.INSERT INTO employees(empno,ename,job) VALUES (2001,'Harry','CLERK');

B. LOCK TABLE employees IN EXCLUSIVE MODE;

C. SELECT empno,ename FROM employees WHERE job='CLERK';

D. SELECT job FROM employees WHERE job='CLERK' FOR UPDATE OF empno;

E. INSERT INTO employees(empno,ename) VALUES (1289,'Dick');

Answer: BD

【解析】

使用FOR UPDATE子句可以锁定选定的行,以便其他用户在结束事务之前不能锁定或更新该行。只能在顶级SELECT语句中指定此子句,而不能在子查询中指定此子句。

加上OF ... column子句仅锁定联接中特定表或视图的选择行。OF子句中的列仅指示锁定的表或视图行,您指定的特定列并不重要。 但是,必须指定实际的列名,而不是列别名。如果省略此子句,则数据库将锁定查询中所有表中的选定行。

【官方手册】

https://docs.oracle.com/en/da...

你可能感兴趣的