0. 参见 mysql\Docs\manual.html
1. 4.0以上mysqld都支持事务,包括非max版本。3.23的需要max版本mysqld才能支持事务。
2. 创建表时如果不指定type则默认为myisam,不支持事务。 可以用 show create table tablename 命令看表的类型。
2.1 对不支持事务的表做start/commit操作没有任何效果,在执行commit前已经提交,测试: 执行一个msyql: use test; drop table if exists tn; create table tn (a varchar(10)) type=myisam; drop table if exists ty; create table ty (a varchar(10)) type=innodb;
begin; insert into tn values('a'); insert into ty values('a'); select * from tn; select * from ty; 都能看到一条记录
执行另一个mysql: use test; select * from tn; select * from ty; 只有tn能看到一条记录 然后在另一边 commit; 才都能看到记录。
3. 可以执行以下命令来切换非事务表到事务(数据不会丢失),innodb表比myisam表更安全: alter table tablename type=innodb;
3.1 innodb表不能用repair table命令和myisamchk -r table_name 但可以用check table,以及mysqlcheck [OPTIONS] database [tables]
4. 启动mysql数据库的命令行中添加了以下参数可以使新发布的mysql数据表都默认为使用事务( 只影响到create语句。) --default-table-type=InnoDB
测试命令: use test; drop table if exists tn; create table tn (a varchar(10)); show create table tn;
5. 临时改变默认表类型可以用: set table_type=InnoDB; show variables like 'table_type'; 或: c:\mysql\bin\mysqld-max-nt --standalone --default-table-type=InnoDB 
|