首页 > 数据库技术 > 详细

MySQL数据库 行超限

时间:2017-06-19 16:59:05      阅读:496      评论:0      收藏:0      [点我收藏+]

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



root@localhost 03:54:  [test]> create table t4(c int, c2 char(30), c3 varchar(21813)) charset=utf8;

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

root@localhost 03:55:  [test]> create table t4(c int, c2 char(30), c3 varchar(21812)) charset=utf8;

Query OK, 0 rows affected (0.04 sec)


字符类型若为gbk,每个字符最多占2个字节,最大长度不能超过32766; 

字符类型若为utf8,每个字符最多占3个字节,最大长度不能超过21845。 


则此处N的最大值为 (65535-1-2-4-30*3)/3=21812 

减1的原因是实际行存储从第二个字节开始‘; 

减2的原因是varchar头部的2个字节表示长度; 

减4的原因是int类型的c占4个字节; 

减30*3的原因是char(30)占用90个字节,编码是utf8。 


mysql的vachar字段的类型虽然最大长度是65535,但是并不是能存这么多数据,最大可以到65533(不允许非空字段的时候),当允许非空字段的时候只能到65532。 


本文出自 “晴空” 博客,谢绝转载!

MySQL数据库 行超限

原文:http://hexudong.blog.51cto.com/7169867/1939795

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!