What is the main difference between Lock , Block and Deadlock in oracle database:

What is the main difference between Lock , Block and Deadlock in oracle database:
Answer :
The Meaning of lock is :
========================
Lock is a done by database when any connection access a same piece of data concurrently.
One connection need to access Piece of data .
The Meaning of Block :
======================
It occurs when two connections need access to same piece of data concurrently and the meanwhile another
is blocked because at a particular time, only one connection can have access. SQL knows that once the blocking process
finishes the resource will be available and so the blocked process will wait (until it times out), but it won’t be
killed.
The Meaning of Deadlock :
=========================
Deadlock occurs when one connection is blocked and waiting for a second to complete its work,
and this situation is again with another process as it waiting for first connection to release the lock.
Hence deadlock occurs.
Example :
i have 2 processes. P1 & P2 trying to get to 2 resources R1 & R2.
P1 gets a lock on R1
and
P2 gets a lock on R2
THEN
P1 tries to get a lock on R2 but can’t because it is locked by P2
and
P2 tries to get a lock on R1 but can’t because it is locked by P1
in this point no process can finish because they are waiting on locked resources. they are deadlocked.
One of them must be killed to allow either of them to finish.

Comments

Popular posts from this blog

Troubleshooting EBS login page issue in R12.2:

Oracle Apps EBS R12.2 Login Flow

Oracle apps dba Interview Q&A's