首页 数据库 mysql教程 [MySQL 错误]ERROR 1118 (42000): Row size too large. The maxi_MySQL

[MySQL 错误]ERROR 1118 (42000): Row size too large. The maxi_MySQL

Jun 01, 2016 pm 01:27 PM
朋友

bitsCN.com

[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. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.

原来有N有255这样一个坎啊,超过了N的意义就不一样了。

后续测试1 ,朋友木木说是字符集的问题,那么我就执行之前设置下字符集,不过还是报错,但是我在SQLyog工具的窗口里面执行是成功(工具里面自动转变成mediumtext类型了)。

[MySQL 错误]ERROR 1118 (42000): Row size too large. The maxi_MySQL

mysql> set names utf8;  Query OK, 0 rows affected (0.00 sec)      mysql> DROP TABLE ttt;  ERROR 1051 (42S02): Unknown table 'test.ttt'  mysql> CREATE TABLE `ttt` (      -> `id` DOUBLE ,      -> `select_type` VARCHAR (57),      -> `table` VARCHAR (192),      -> `type` VARCHAR (65535),      -> `key` VARCHAR(20),      -> `possible_keys` VARCHAR (100),      -> `key_len`  VARCHAR (65535),      -> `ref` VARCHAR (11),      -> `rows` DOUBLE ,      -> `Extra` VARCHAR (765)      -> );   ERROR 1074 (42000): Column length too big for column 'type' (max = 21845); use BLOB or TEXT instead  mysql> set names gbk;  Query OK, 0 rows affected (0.00 sec)      mysql> DROP TABLE ttt;  ERROR 1051 (42S02): Unknown table 'test.ttt'  mysql> CREATE TABLE `ttt` (      -> `id` DOUBLE ,      -> `select_type` VARCHAR (57),      -> `table` VARCHAR (192),      -> `type` VARCHAR (65535),      -> `key` VARCHAR(20),      -> `possible_keys` VARCHAR (100),      -> `key_len`  VARCHAR (65535),      -> `ref` VARCHAR (11),      -> `rows` DOUBLE ,      -> `Extra` VARCHAR (765)      -> );   ERROR 1074 (42000): Column length too big for column 'type' (max = 21845); use BLOB or TEXT instead  mysql>  
登录后复制

 

 

最后总结:这个可能是超过 一个表 关于 非十六进制字段 64k的限制了。

上官网:http://dev.mysql.com/doc/refman/5.5/en/column-count-limit.html:

Every table (regardless of storage engine) has a maximum row size of 65,535 bytes. Storage engines may place additional constraints on this limit, reducing the effective maximum row size.

65,535所说明的是针对的是整个表的非大字段类型的字段的bytes总合。

bitsCN.com
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
2 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
2 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
2 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

如何使用Alter Table语句在MySQL中更改表? 如何使用Alter Table语句在MySQL中更改表? Mar 19, 2025 pm 03:51 PM

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

如何为MySQL连接配置SSL/TLS加密? 如何为MySQL连接配置SSL/TLS加密? Mar 18, 2025 pm 12:01 PM

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

您如何处理MySQL中的大型数据集? 您如何处理MySQL中的大型数据集? Mar 21, 2025 pm 12:15 PM

文章讨论了处理MySQL中大型数据集的策略,包括分区,碎片,索引和查询优化。

哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? 哪些流行的MySQL GUI工具(例如MySQL Workbench,PhpMyAdmin)是什么? Mar 21, 2025 pm 06:28 PM

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

如何使用Drop Table语句将表放入MySQL中? 如何使用Drop Table语句将表放入MySQL中? Mar 19, 2025 pm 03:52 PM

本文讨论了使用Drop Table语句在MySQL中放下表,并强调了预防措施和风险。它强调,没有备份,该动作是不可逆转的,详细介绍了恢复方法和潜在的生产环境危害。

您如何用外国钥匙代表关系? 您如何用外国钥匙代表关系? Mar 19, 2025 pm 03:48 PM

文章讨论了使用外国密钥来代表数据库中的关系,重点是最佳实践,数据完整性和避免的常见陷阱。

如何在JSON列上创建索引? 如何在JSON列上创建索引? Mar 21, 2025 pm 12:13 PM

本文讨论了在PostgreSQL,MySQL和MongoDB等各个数据库中的JSON列上创建索引,以增强查询性能。它解释了索引特定的JSON路径的语法和好处,并列出了支持的数据库系统。

如何保护MySQL免受常见漏洞(SQL注入,蛮力攻击)? 如何保护MySQL免受常见漏洞(SQL注入,蛮力攻击)? Mar 18, 2025 pm 12:00 PM

文章讨论了使用准备好的语句,输入验证和强密码策略确保针对SQL注入和蛮力攻击的MySQL。(159个字符)

See all articles