26.7k views
2 votes
Suppose two client sessions are connected to a single database table, if session one issues a read lock on the table:

What would happen if session one issues a write command to the locked table?

What would happen if session two issues a write command to the locked table?

1 Answer

4 votes

Final answer:

If session one issues a read lock and then tries to write to the table, it will be blocked. If session two tries to write to the table, it will also be blocked.

Step-by-step explanation:

If session one issues a read lock on the table and then tries to issue a write command to the locked table, it will be blocked. The write command will not be executed until the read lock is released. This is because a read lock allows other sessions to read from the table, but it prevents sessions from making changes to the table.

If session two tries to issue a write command to the locked table, it will also be blocked. The write command from session two will have to wait for the read lock to be released by session one before it can be executed.

User Mtrakal
by
8.8k points

No related questions found