11. Latch and Lock - sayanbhattacharya1234/Oracle_DBA GitHub Wiki
Latch means = temporary locking mechanism where lock and unlock is quick switchable.
Lock means = parmanet locking system where we do lock only need a key to unlock .
Q . A scenario where 2 user Rohit and Robin are try to update a same dml record then what will happen,
suppose 2 users are conn by two terminals. rohit have a table TAB . this table access to Robin user . and they try to update a same record.
now same record update
update successfully in rohit user
.
but in robin user the cursor is blinking
Main reason
In architechture, datablocks are there , when a record updated in datablock, current datablock transfer to the undo datablock. and the address of the undo datablock will store in this datablock.
so that a user comes with a quary we can get the priv values from undo datafile. call read consistancy.
In these scenario a user transaction done to update a record but he hasn't completed the transaction . so whenever a transaction done to there will be a lock applied on the particular row. in that case A transaction will retain its lock until it completes its work (Commit/Rollback). When you do commit then lock will released.
view to chech a row lock or not.
2 ways to unlock the row lock transaction >>>
i> As a DBA i can kill this rohit user session activity , before kill the session i get a mail from my senior or management . i'm killing this activity its something happend i'm not responsible for this .
command is > alter system kill session 'sid,serial' immediate;
ii> if user commit or rollback then row lock released.