MySQL中的innodb_file_format 配置项解读
一:innodb_file_format参数
在 innodb 1.0.6版本之前,innodb文件格式innodb_file_format
只有 Antelope(Antelope 文件格式支持Redundant,Compact两种格式来存放行记录,Redundant是为了兼容之前版本而保留的。在mysql 5.1版本中,默认设置为Compact,用户可以通过 show table status like 'table_name'
来查看表使用的行格式row_format)
从innodb 1.0.6开始引入了新的文件格式 Barracuda 在原来的基础上(Antelope)新增了Dynamic和Compressed两种行格式。
二:innodb_file_format如何使用
一般, innodb_file_format
在配置文件中指定;row_format
则在创建数据表时指定:
CREATE TABLE test2 (column1 INT PRIMARY KEY)
ENGINE=InnoDB ROW_FORMAT=Compressed KEY_BLOCK_SIZE=4;
三:innodb_file_format = Barracuda
在指定innodb_file_format = Barracuda时,建议配合如下参数一起使用
innodb_file_format_max = Barracuda
innodb_strict_mode = 1
innodb_file_per_table = 1
因为system tablespace使用的是Antelope文件格式,如果不指定innodb_file_per_table = 1(5.6.6是默认开启的),那么innodb表被存储在system tablespace,这时在建表的时候无法使用Dynamic和Compressed两种行格式(如果设置了innodb_strict_mode = 1,那么建表的时候指定Dynamic和Compressed会直接报错。如果没有指定innodb_strict_mode = 1,建表的时候指定Dynamic和Compressed会被忽略,默认设置为Compact)
关于innodb_strict_mode参数介绍:
innodb_strict_mode
Command-Line Format –innodb_strict_mode=# System Variable Name innodb_strict_mode Variable Scope Global, Session Dynamic Variable Yes Permitted Values Type boolean Default OFF When innodb_strict_mode is ON, InnoDB returns errors rather than warnings for certain conditions. The default value is OFF.
By admin
read more