Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How Deadlock situation occurs?

0
Posted

How Deadlock situation occurs?

0

Deadlock is a situation that occurs when two or more users are waiting for data locked by each other. Oracle automatically detects a deadlock and resolves them by rolling back one of the statements involved in the deadlock. The example below demonstrates how deadlock occurs. Suppose there is a table test with two rows. create table test ( row_row_num row_number, txt varchar2(10) ); insert into test values ( 1, ‘First’ ); insert into test values ( 2, ‘Second’ ); commit; SQL> Select * from test ; ROW_NUM TXT 1 First 2 Second Ses#1: Issue the following command: SQL> update test set txt=’ses1′ where row_num=1; Ses#2: Issue the following command: SQL> update test set txt=’ses2′ where row_num=2; SQL> update test set txt=’ses2′ where row_num=1; Ses#2 is now waiting for the lock held by Ses#1 Ses#1: Issue the following command: SQL> update test set txt=’ses1′ where row_num=2; This update would cause Ses#1 to wait on the lock held by Ses#2, but Ses#2 is already waiting on this session.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.