View the Exhibit and examine the structure of the ORDERS and CUSTOMERS tables.
Evaluate the following SQL command:
SQL> SELECT o.order_id, c.cust_name, o.order_total, c.credit_limit
FROM orders o JOIN customers c
USING (customer_id)
WHERE o.order_total > c.credit_limit
FOR UPDATE
ORDER BY o.order_id;
Which two statements are true regarding the outcome of the above query? (Choose two.)
A.
It locks all the rows that satisfy the condition in the statement.
B.
It locks only the columns that satisfy the condition in both the tables.
C.
The locks are released only when a COMMIT or ROLLBACK is issued.
D.
The locks are released after a DML statement is executed on the locked rows.
Explanation:
FOR UPDATE Clause in a SELECT Statement
Locks the rows in the EMPLOYEES table where job_id is SA_REP.
Lock is released only when you issue a ROLLBACK or a COMMIT.
If the SELECT statement attempts to lock a row that is locked by another user, the database
waits until the row is available, and then returns the results of the
SELECTstatement
SELECT employee_id, salary, commission_pct, job_id
FROM employees
WHERE job_id = ‘SA_REP’
FOR UPDATE
ORDER BY employee_id;
It will lock only the rows where condition satisfies.