Mysql数据表引擎及事务回滚机制
1、查看当前支持的数据引擎mysql> show engines;+------------+---------+------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES| YES |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables| NO | NO | NO |
+------------+---------+------------------------------------------------------------+--------------+------+------------+
5 rows in set (0.00 sec)
mysql>2、查看数据表引擎mysql> show create table books \G
*************************** 1. row ***************************
Table: books
Create Table: CREATE TABLE `books` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`bookname` char(50) NOT NULL DEFAULT '',
`publisher` char(80) NOT NULL DEFAULT '',
`author` char(30) NOT NULL DEFAULT '',
`price` double NOT NULL DEFAULT '0',
`ptime` int(11) NOT NULL DEFAULT '0',
`pic` char(40) NOT NULL DEFAULT '',
`detail` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql> 3、修改数据表引擎mysql> alter table books engine=innodb;Query OK, 98 rows affected (0.07 sec)
Records: 98 Duplicates: 0 Warnings: 0
mysql> 4、关闭数据自动提交mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)5、开启一个事务mysql> begin;
Query OK, 0 rows affected (0.00 sec)6、回滚mysql> rollback;
Query OK, 0 rows affected (0.00 sec)7、提交事务mysql> commit;
Query OK, 0 rows affected (0.00 sec)
页:
[1]