Use transaction rollback need to shut down automatically submit first, set the autocommit=off, this is the session level Settings, each time the reconnection need to reset the
You can use normally after transaction rollback the
by default, MySQL USES the autocommit mode operation, this means that when performing the update table statement, MySQL immediately to update stored to disk,
Transaction secure storage engines (such as InnoDB, BDB or NDB cluster),
Use this statement to disable autocommit mode:
SET the AUTOCOMMIT=0;
Use START the TRANSACTION, the autocommit mode is disabled, still until the end of COMMIT or ROLLBACK TRANSACTION, then the autocommit mode to restore to its original state,
Mysql> Select * from the test_main//
+ - + -- -- -- -- -- -- -- +
| id value | |
+ - + -- -- -- -- -- -- -- +
| 1 | ONE |
| | 2 TWO |
| 3 | THREE |
+ - + -- -- -- -- -- -- -- +
3 rows in the set (0.00 SEC)
Mysql> START the TRANSACTION;
->//
Query OK, 0 rows affected (0.00 SEC)
Mysql> INSERT INTO the test_main VALUES (4, 'FOUR')//
Query OK, 1 row affected (0.00 SEC)
Mysql> INSERT INTO the test_main VALUES (4, 'FOUR')//
ERROR 1062 (23000) : Duplicate entry '4' for key 'PRIMARY'
Mysql> The ROLLBACK//
Query OK, 0 rows affected (0.01 SEC)
Mysql> Select * from the test_main//
+ - + -- -- -- -- -- -- -- +
| id value | |
+ - + -- -- -- -- -- -- -- +
| 1 | ONE |
| | 2 TWO |
| 3 | THREE |
+ - + -- -- -- -- -- -- -- +
3 rows in the set (0.00 SEC)
MSSQL how to write?
CodePudding user response:
You asked the mysql MSSQL, so what are you want to ask?CodePudding user response:
Want to know one by one on the MSSQL is how to write! This is a mysql: excuse me, do you MSSQL is how to write