日期:2014-05-16 浏览次数:21012 次
mysql> start transaction;
mysql> delete from test_inn;
mysql> select * from test_inn;
Empty set (0.00 sec)
mysql> rollback;
mysql> select * from test_inn;
+------+------------+
| id | birthday |
+------+------------+
| 1 | 2012-12-12 |
| 1 | 0000-00-00 |
| 1 | 2012-12-00 |
| 1 | 0000-00-00 |
+------+------------+
mysql> show create table test_inn;
+----------+----------------------------
| Table | Create Table
+----------+----------------------------
| test_inn | CREATE TABLE `test_inn` (
`id` int(11) DEFAULT NULL,
`birthday` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
+----------+---------------------------- 注意:上例中表test_inn使用的是InnoDB引擎,若一个使用MyISAM引擎的表执行如上操作,则即使ROLLBACK后,可以发现,数据仍然被实实在在的清空。 mysql> start transaction;
mysql> delete from test_inn;
mysql> commit; 当COMMIT或ROLLBACK语句执行后,启动的事务会自动关闭。