MySQL每个表有4096个列的硬限制,MySQL表的最大行大小限制为65535字节
-- innodb_page_size
show variables like 'innodb_page_size';
-- 文件格式
show variables like 'innodb_file_format';
-- 行格式
show table status like 'table_name';
(一).innodb_page_size, 行溢出
(1).当所有字段总和大于 半个page,varchar就溢出.
(2). innodb_文件格式 与 innodb_行格式
antelope - Compact / Redundant 羚羊-紧凑/冗余 (768byte)
是否溢出:列的值为768个字节或更少,则不需要溢出页面(包含text类型)
溢出方式:数据页保存前768个字节,其余的则存储在溢出页面中
Barracuda - dynamic / compress 梭子鱼-动态/压缩
是否溢出:dynamic行格式,列存储是否放到off-page页,主要取决于行大小,它会把行中最长的那一列放到off,直到数据页能存放下两行.
溢出方式:数据页只包含指向溢出页面的20字节指针,TEXT/BLOB小于或等于40字节的列总是在线存储的。
(二).innodb 最大行限制:最大行大小限制为65535字节
(1).单个字段如果大于65535,则转换为TEXT 。
(2).单行最大限制为65535,这里不包括TEXT、BLOB。
参考:
https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format-dynamic.html
https://dev.mysql.com/doc/refman/5.7/en/innodb-row-format-antelope.html
https://www.cnblogs.com/chenpingzhao/p/6719258.html