一般来说,MySQL有以下几种引擎:ISAM、MyISAM、HEAP、InnoDB和Berkley(BDB)。注意:不同的版本支持的引擎是有差异的。当然啦,如果你感觉自己的确技术高超,你还能够使用MySQL++来创建自己的数据库引擎,这个已经outof my knowledge,牛人可以参照MySQL++API帮助来实现。下面逐一叙述这5种引擎各自的特性:
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;
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:mysqlbinmysqld-max-nt –standalone –default-table-type=InnoDB