innodb 和 myisam的区别

有一张type表存储引擎为innodb

mysql> show create table type\G
*************************** 1. row ***************************
       Table: type
Create Table: CREATE TABLE `type` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL,
  `var_name` char(12) NOT NULL DEFAULT '',
  `img_width` int(5) DEFAULT NULL,
  `img_height` int(5) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8

有一张book表存储引擎为myisam

CREATE TABLE `book` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `book_name` varchar(255) DEFAULT NULL,
  `book_desc` varchar(255) DEFAULT NULL,
  `book_number` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8

一:存储的文件形式不同
innodb
type.frm
type.ibd

.frm 文件 官方解释如下
MySQL stores its data dictionary information for tables in .frm files in database directories. Unlike other MySQL storage engines, InnoDB also encodes information about the table in its own internal data dictionary inside the tablespace. When MySQL drops a table or a database, it deletes one or more .frm files as well as the corresponding entries inside the InnoDB data dictionary. You cannot move InnoDB tables between databases simply by moving the .frm files.
.frm 文件存储的是结构信息
.ibd 文件存储的是数据信息

myisam
book.frm 表信息
book.MYD 数据文件(data)
book.MYI 索引文件(index)

二:innodb支持事务,myisam不支持事务。

  • type表为innodb引擎

innodb支持事务

  • book表为myisam引擎

myisam不支持事务

建议看下 《InnoDB存储引擎第二版》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值