I am learning how transactions work using this short script
CREATE TABLE t_test (id INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
START TRANSACTION;
INSERT
INTO t_test
VALUES (1);
SELECT *
FROM t_test;
id
---
1
SAVEPOINT tran2;
INSERT
INTO t_test
VALUES (2);
SELECT *
FROM t_test;
id
---
1
2
ROLLBACK TO tran2;
SELECT *
FROM t_test;
id
---
1
ROLLBACK;
SELECT *
FROM t_test;
id
---
Towards the end,ROLLBACK
a savepoint is used.Does it mean when ROLLBACK
is used it wipes out everything that was commited earlier on?.
Secondly,what if i edit the table outside of the transaction and the try ROLLBACK TO trans2
for instance,what happens?.
Aucun commentaire:
Enregistrer un commentaire