Select*frommarks;+------+----------+-----------+-- -----+|Id |Name |Subject |Marks|+------+---------+-----------"/> Select*frommarks;+------+----------+-----------+-- -----+|Id |Name |Subject |Marks|+------+---------+-----------">
#Assume that if the session ends in a transaction, the current MySQL transaction will be rolled back by MySQL and ended. This means that all database changes made in the current transaction will be deleted. The end of the session is called an implicit rollback.
Suppose we have the following values in the table "marks"
mysql> Select * from marks; +------+---------+-----------+-------+ | Id | Name | Subject | Marks | +------+---------+-----------+-------+ | 1 | Aarav | Maths | 50 | | 1 | Harshit | Maths | 55 | | 3 | Gaurav | Comp | 69 | | 4 | Rahul | History | 40 | | 5 | Yashraj | English | 48 | | 6 | Manak | History | 70 | +------+---------+-----------+-------+ 6 rows in set (0.00 sec) mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> UPDATE marks SET Name = ‘Yash’ Where id = 5; Query OK, 1 row affected (0.06 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> quit; Bye
In the above example, after updating the values in the table, end the session by running the quit statement . When we look at the table after starting the session again, the updated values have been rolled back by MySQL because the session ended in a transaction.
The above is the detailed content of What happens to the current MySQL transaction if the session ends mid-transaction?. For more information, please follow other related articles on the PHP Chinese website!