80.9k views
0 votes
Which keywords create a shared lock on a table to prevent another user from making changes to data in specified columns?​

a. LOCK IN
b. SHARE LOCK
c. FOR UPDATE
d. PREVENT CHANGE

1 Answer

7 votes

Final answer:

c. FOR UPDATE. The correct keyword that creates a shared lock on a table to prevent another user from making changes to data in specified columns is FOR UPDATE.

Step-by-step explanation:

​The correct keyword that creates a shared lock on a table to prevent another user from making changes to data in specified columns is FOR UPDATE.

When the FOR UPDATE keyword is used in a SQL SELECT statement, it acquires a shared lock on the selected rows, preventing any other user from modifying those rows until the lock is released. This is particularly useful in multi-user environments where data consistency is important.

For example, consider the following SQL statement:

SELECT * FROM table_name FOR UPDATE;

This statement will retrieve all the rows from table_name and place a shared lock on them, ensuring that no other user can modify the data until the lock is released.

User Daniel LeCheminant
by
8.1k points