Home     My Faqts     Contributors     About     Help    

faqts : Computers : Databases : MySQL : Tips and Tricks

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

1 of 1 people (100%) answered Yes
Recently 1 of 1 people (100%) answered Yes

How do you rollback a transaction in MySQL?

Jun 20th, 2004 00:15

Mike Chirico
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download


TIP 7:
Transactions: Not all table types support transactions. BDB and INNODB 
type do support transactions.  Assuming the server has NOT been started 
with --skip-bdb or --skip-innodb the following should work:
mysql> create table tran_test (a int, b int) type = InnoDB;
mysql> begin;
mysql> insert into tran_test (a,b) values (1,2);
mysql> select * from tran_test;         
select * from tran_test;                
+------+------+                         
| a    | b    |                         
+------+------+                         
|    1 |    2 |                         
+------+------+                         
 1 row in set (0.00 sec)                 
mysql> rollback;
mysql> select * from tran_test;  
select * from tran_test;         
Empty set (0.00 sec)             
Note, the entry above was not saved.
Summary: rollback undoes everything and commit will save.
For more tips reference:
http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
Hope this helps,
Mike Chirico



© 1999-2004 Synop Pty Ltd