mysql innodb 表行大小限制(Row Size Limit)
遵循2个规则,这个两个规则必须同时遵守,但对于innodb 引擎表而言单表行大小不能大于: 1/2(innodb_page_size):
#1:maximum row size limit of 65,535 bytes
#2:InnoDB restricts row size (for data stored locally within the database page) to slightly less than half
a database page for 4KB, 8KB, 16KB, and 32KB innodb_page_size settings
####报错规则
如果表的行大小超过65535. 直接报错:ERROR 1118 (42000): Row size too large.
如果表的行大小超过8126 但是小于65535 报错信息为:ERROR 1118 (42000): Row size too large (> 8126)
mysql>CREATE TABLE t4 (
-> c1 CHAR(255),c2 CHAR(255),c3 CHAR(255),
-> c4 CHAR(255),c5 CHAR(255),c6 CHAR(255),
-> c7 CHAR(255),c8 CHAR(255),c9 CHAR(255),
-> c10 CHAR(255),c11 CHAR(255),c12 CHAR(255),
-> c13 CHAR(255),c14 CHAR(255),c15 CHAR(255),
-> c16 CHAR(255),c17 CHAR(255),c18 CHAR(255),
-> c19 CHAR(255),c20 CHAR(255),c21 CHAR(255),
-> c22 CHAR(255),c23 CHAR(255),c24 CHAR(255),
-> c25 CHAR(255),c26 CHAR(255),c27 CHAR(255),
-> c28 CHAR(255),c29 CHAR(255),c30 CHAR(255),
-> c31 CHAR(255),c32 CHAR(255),c33 CHAR(255),c34 blob,c35 varchar(27120)
-> ) ENGINE=InnoDB ROW_FORMAT=COMPACT DEFAULT CHARSET latin1;
ERROR 1118 (42000): Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
mysq> CREATE TABLE t4 (
-> c1 CHAR(255),c2 CHAR(255),c3 CHAR(255),
-> c4 CHAR(255),c5 CHAR(255),c6 CHAR(255),
-> c7 CHAR(255),c8 CHAR(255),c9 CHAR(255),
-> c10 CHAR(255),c11 CHAR(255),c12 CHAR(255),
-> c13 CHAR(255),c14 CHAR(255),c15 CHAR(255),
-> c16 CHAR(255),c17 CHAR(255),c18 CHAR(255),
-> c19 CHAR(255),c20 CHAR(255),c21 CHAR(255),
-> c22 CHAR(255),c23 CHAR(255),c24 CHAR(255),
-> c25 CHAR(255),c26 CHAR(255),c27 CHAR(255),
-> c28 CHAR(255),c29 CHAR(255),c30 CHAR(255),
-> c31 CHAR(255),c32 CHAR(255),c33 CHAR(255),c34 blob,c35 varchar(65535)
-> ) ENGINE=InnoDB ROW_FORMAT=COMPACT DEFAULT CHARSET latin1;
ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs