exam questions

Exam 1z0-061 All Questions

View all questions & answers for the 1z0-061 exam

Exam 1z0-061 topic 4 question 78 discussion

Actual exam question from Oracle's 1z0-061
Question #: 78
Topic #: 4
[All 1z0-061 Questions]

Which statements are true regarding the FOR UPDATE clause in a SELECT statement? (Choose all that apply.)

  • A. It locks only the columns specified in the SELECT list.
  • B. It locks the rows that satisfy the condition in the SELECT statement.
  • C. It can be used only in SELECT statements that are based on a single table.
  • D. It can be used in SELECT statements that are based on a single or multiple tables.
  • E. After it is enforced by a SELECT statement, no other query can access the same rows until a COMMIT or ROLLBACK is issued.
Show Suggested Answer Hide Answer
Suggested Answer: BD 🗳️
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
SELECT statement.
FOR UPDATE Clause in a SELECT Statement
When you issue a SELECT statement against the database to query some records, no locks are placed on the selected rows. In general, this is required because the number of records locked at any given time is (by default) kept to the absolute minimum: only those records that have been changed but not yet committed are locked. Even then, others will be able to read those records as they appeared before the change (the "before image" of the data). There are times, however, when you may want to lock a set of records even before you change them in your program.
Oracle offers the FOR UPDATE clause of the SELECT statement to perform this locking. When you issue a SELECT...FOR UPDATE statement, the relational database management system (RDBMS) automatically obtains exclusive row-level locks on all the rows identified by the SELECT statement, thereby holding the records "for your changes only." No one else will be able to change any of these records until you perform a ROLLBACK or a COMMIT.
You can append the optional keyword NOWAIT to the FOR UPDATE clause to tell the Oracle server not to wait if the table has been locked by another user. In this case, control will be returned immediately to your program or to your SQL Developer environment so that you can perform other work, or simply wait for a period of time before trying again. Without the NOWAIT clause, your process will block until the table is available, when the locks are released by the other user through the issue of a COMMIT or a ROLLBACK command.

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
hggz
5 years, 9 months ago
I think BDE is correct
upvoted 1 times
hggz
5 years, 9 months ago
Locking Mechanism (Student book) Locks are implemented by Oracle Database 12c to prevent destructive interaction between concurrent transactions. Locks are acquired automatically by Oracle when a DML statement is executed; no user intervention or action is needed. Oracle uses the lowest level of restrictiveness when locking data for DML statements—only the rows affected by the DML operation are locked. Locks are held for the duration of the transaction. A commit or rollback will release all the locks. There are two types of locks: explicit and implicit. The locks acquired by Oracle automatically when DML operations are performed are called implicit locks. There is no implicit lock for SELECT statements. If the user locks data manually, it is called explicit locking. The LOCK TABLE statement and SELECT…FOR UPDATE statements are used for explicitly locking the data.
upvoted 1 times
...
hggz
5 years, 9 months ago
Locking Mechanism (Student book) The SELECT…FOR UPDATE statement is used to lock specific rows, preventing other sessions from changing or deleting those locked rows. When the rows are locked, other sessions can select these rows, but they cannot change or lock these rows. The syntax for this statement is identical to a SELECT statement, except you append the keywords FOR UPDATE to the statement. The locks acquired for a SELECT FOR UPDATE will not be released until the transaction ends with a COMMIT or ROLLBACK, even if no data changes.
upvoted 1 times
...
...
duongvietnam
5 years, 10 months ago
E is correct answer
upvoted 1 times
hggz
5 years, 9 months ago
Locking Mechanism (Student book) Locks are implemented by Oracle Database 12c to prevent destructive interaction between concurrent transactions. Locks are acquired automatically by Oracle when a DML statement is executed; no user intervention or action is needed. Oracle uses the lowest level of restrictiveness when locking data for DML statements—only the rows affected by the DML operation are locked. Locks are held for the duration of the transaction. A commit or rollback will release all the locks. There are two types of locks: explicit and implicit. The locks acquired by Oracle automatically when DML operations are performed are called implicit locks. There is no implicit lock for SELECT statements. If the user locks data manually, it is called explicit locking. The LOCK TABLE statement and SELECT…FOR UPDATE statements are used for explicitly locking the data.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...