Re: Does the row (table of database) lock hold during the transaction?

From: D.Y. <dyou98_at_aol.com>
Date: 9 Jul 2002 14:21:41 -0700
Message-ID: <f369a0eb.0207091321.88b6d3d_at_posting.google.com>


wqhdebian_at_263.net (wqhdebian) wrote in message news:<db288b61.0207081736.58da7c13_at_posting.google.com>...
> In a tranction,a update event happened, and it will lock the
> associated row of the table.after the update's completeness,and before
> the tranction rollbacks or commits,whether or not the row lock will
> hold?
>
> I see from a book that in the following condition ,a dead lock will
> happen.
>
>
> transaction 1:
> UPDATE sales.parts SET onhand=onhand-10 WHERE id=1; //lock 1
> UPDATE sales.parts SET onhand=onhand-10 WHERE id=2; //lock 2
> ////waiting for transation 2 to release lock 2
>
>
> transaction 2:
> UPDATE sales.parts SET onhand=onhand-10 WHERE id=2; //lock
> 2
> UPDATE sales.parts SET onhand=onhand-10 WHERE id=1; //lock
> 1
> ////waiting for transation 2 to release lock 1
>
> And I infer from this ,the lock will hold until the transaction
> commits or rollbacks ,is it right?

That's correct. Received on Tue Jul 09 2002 - 23:21:41 CEST

Original text of this message