5、大文本类型
5.1 MySQL中每一行存储的数据是有大小限制的,每一行最多只能存储65534个字节
例如:
create table if not exists person8(
name1 char(3),
name2 varchar(21845)
) charset=utf8;
系统会报错:1118 - 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
原因是varchar的21845*3=65535实际占用65535字节 ,name2字段已经超过了每一行最多只能存储65534个字节限制。所以会报错
5.2 大文本类型
TINYTEXT 0-255字节 短文本字符串
TEXT 0-65535字节 长文本数据
MEDIUMTEXT 0-16777215字节 中等长度文本数据
LONGTEXT 0-4294967295字节 极大文本数据
create table if not exists person9(
name1 char(3),
name2 text
)charset=utf8;
注意点:大文本类型在表中并不会实际占用所能保存的字节数,而是利用10个字节引用了实际保存数据的地址