设为首页 加入收藏

TOP

[MySQL 错误]ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not解决(一)
2014-11-23 20:25:40 来源: 作者: 【 】 浏览:33
Tags:MySQL 错误 ERROR 1118 42000 Row size too large. The maximum row for the used table type not 解决
[MySQL 错误]ERROR 1118 (42000): Row size too large. The maximum row size for the used table type, not解决
朋友发过来一个SQL,,让我执行以下:
CREATE TABLE `ttt` (  
    `id` DOUBLE ,  
    `select_type` VARCHAR (57),  
    `table` VARCHAR (192),  
    `type` VARCHAR (30),  
    `possible_keys` VARCHAR (22288),  
    `key` VARCHAR (192),  
    `key_len` VARCHAR (22288),  
    `ref` VARCHAR (3072),  
    `rows` DOUBLE ,  
    `Extra` VARCHAR (765)  
);   
INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('1','PRIMARY','aaa','index',NULL,'email_2','51',NULL,'5','Using where; Using index');  
INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('2','DEPENDENT SUBQUERY','bbb','ref','id','id','5','test.aaa.id','1','Using where; Using index');  

执行第一句建表的时候就卡住了,报错如下:
mysql> CREATE TABLE `ttt` (  
    -> `id` DOUBLE ,  
    -> `select_type` VARCHAR (57),  
    -> `table` VARCHAR (192),  
    -> `type` VARCHAR (30),  
    -> `possible_keys` VARCHAR (12288),  
    -> `key` VARCHAR (192),  
    -> `key_len` VARCHAR (12288),  
    -> `ref` VARCHAR (3072),  
    -> `rows` DOUBLE ,  
    -> `Extra` VARCHAR (765)  
    -> );   
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  
mysql>  

看了提示,表的2个varchar字段长度设置过长了,需要改成text,blob之类的类型,修改之后执行成功了:
mysql> use test;  
Database changed  
mysql>   
mysql> CREATE TABLE `ttt` (  
    -> `id` DOUBLE ,  
    -> `select_type` VARCHAR (57),  
    -> `table` VARCHAR (192),  
    -> `type` VARCHAR (30),  
    -> `possible_keys` TEXT,  
    -> `key` VARCHAR (192),  
    -> `key_len`  TEXT,  
    -> `ref` VARCHAR (3072),  
    -> `rows` DOUBLE ,  
    -> `Extra` VARCHAR (765)  
    -> );   
Query OK, 0 rows affected (0.00 sec)  
  
mysql> INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('1','PRIMARY','aaa','index',NULL,'email_2','51',NULL,'5','Using where; Using index');  
Query OK, 1 row affected (0.04 sec)  
  
mysql> INSERT INTO `ttt` (`id`, `select_type`, `table`, `type`, `possible_keys`, `key`, `key_len`, `ref`, `rows`, `Extra`) VALUES('2','DEPENDENT SUBQUERY','bbb','ref','id','id','5','test.aaa.id','1','Using where; Using index'); 
Query OK, 1 row affected (0.00 sec)  
  
mysql> select * from ttt;  
+------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+  
| id   | select_type        | table | type  | possible_keys | key     | key_len | ref         | rows | Extra                    |  
+------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+  
|    1 | PRIMARY            | aaa   | index | NULL          | email_2 | 51      | NULL        |    5 | Using where; Using index |  
|    2 | DEPENDENT SUBQUERY | bbb   | ref   | id            | id      | 5       | test.aaa.id |    1 | Using where; Using index |  
+------+--------------------+-------+-------+---------------+---------+---------+-------------+------+--------------------------+  
2 rows in set (0.00 sec)  

疑惑:varchar(N),这个N不是最大为65535吗?为什么设置成12288就会报错?12288比65535小很多啊。
有问题上官网:http://dev.mysql.com/doc/refman/5.6/en/char. html
In contrast to CHAR, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MSSQL中视图的架构绑定(SCHEMABI.. 下一篇MySQL批量SQL插入性能优化

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: