How MySQL Transactions query works?


#1

How MySQL Transactions query works?


#2

Let us take an example of a simple query

update candidate set name=“abhinav” where id=3;

Now following the ACID properties of a transaction, either this update will work or fail.

What MYSQL does on the arrival of this query-

  1. LOCK that row as soon as the transaction begins.
  2. MYSQL will create a copy for that row.
  3. update will work on the copied data, not on the original one.

Till this time no change has been made to the actual database. And now hitting the last nail in the coffin.
4. Committing the changes to the actual table

This is how transaction works in update