Wednesday, January 13, 2010

Transaction with MySQL

SET autocommit=0;
START TRANSACTION;
DROP TABLE IF EXISTS tbl_test;
CREATE TABLE tbl_test(a int, b int);
INSERT INTO tbl_test(a,b) VALUES(1,2);
COMMIT;
INSERT INTO tbl_test(a,b) VALUES(3,4);
ROLLBACK;
SELECT * FROM tbl_test;
Return:
a b
1 2

No comments:

Post a Comment