How to Decide to use Database Transactions

后端 未结 6 2276
小鲜肉
小鲜肉 2020-12-11 15:10

How do you guys decide that you should be wrapping the sql in a transaction?

Please throw some light on this.

Cheers !!

6条回答
  •  误落风尘
    2020-12-11 15:53

    if your have more than a single data modifying statement to execute to complete a task, all should be within a transaction.

    This way, if the first one is successful, but any of the following ones has an error, you can rollback (undo) everything as if nothing was ever done.

提交回复
热议问题