We can use the COMMIT command to permanently record the changes made in the current transaction in the MySQL database. Suppose we run some DML statements and update some data objects, then the COMMIT command will permanently record these updates in the database.
mysql> START TRANSACTION; Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO Marks Values(1, 'Aarav','Maths',50); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO Marks Values(2, 'Harshit','Maths',55); Query OK, 1 row affected (0.00 sec) mysql> COMMIT; Query OK, 0 rows affected (0.06 sec)
In this example, the COMMIT statement will explicitly end the transaction, and the changes will be saved, that is, permanently recorded in the database.
mysql> SELECT * FROM Marks; +------+---------+---------+-------+ | Id | Name | Subject | Marks | +------+---------+---------+-------+ | 1 | Aarav | Maths | 50 | | 2 | Harshit | Maths | 55 | +------+---------+---------+-------+ 2 rows in set (0.00 sec)
The above is the detailed content of How to permanently record changes made in the current transaction in a MySQL database?. For more information, please follow other related articles on the PHP Chinese website!