mysql的rows大小超过8126_MySQL:行大小太大(> 8126)

当尝试创建包含300个TEXT字段的表时,遇到了MySQL行大小超过8126字节的错误。尝试使用ROW_FORMAT=COMPRESSED的Barracuda格式并未解决问题。解决方案是重新设计表结构,以符合数据库规范化原则,避免行大小限制问题。
摘要由CSDN通过智能技术生成

我有一张桌子,里面有300列.每列最多255个字节(这有一个商业理由).

当我尝试使用VARCHAR(255)创建它时,我超过了最大字节数的限制.所以我创建的是使用300个TEXT字段.当我尝试插入数据时,我收到错误:

Row size too large (> 8126).

Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help.

In current row format, BLOB prefix of 768 bytes is stored inline.

阅读完之后,我尝试通过指定ROW_FORMAT = COMPRESSED来更改表以使用Barracuda格式.现在的问题似乎是当我尝试使用该格式创建表时,我得到了同样的错误.

CREATE TABLE T_ObjLarge__c (Id VARCHAR(18), Name VARCHAR(80),

ObjLarge_Field_1__c TEXT,

ObjLarge_Field_2__c TEXT,

...

ObjLarge_Field_300__c TEXT

) ROW_FORMAT=COMPRESSED ;

我得到的错误是:

Row size too large (> 8126).

Changing some columns to TEXT or BLOB may help.

In current row format, BLOB prefix of 0 bytes is stored inline.

我在Linux薄荷上使用MySQL 5.5.31.没有索引.我试过DYNAMIC格式;它的行为方式相同.

输出SHOW GLOBAL VARIABLES LIKE’innodb_file_per_table’;:

+--------------------------+-----------+

| Variable_name | Value |

+--------------------------+-----------+

| innodb_file_format | Barracuda |

| innodb_file_format_check | ON |

| innodb_file_format_max | Barracuda |

| innodb_file_per_table | ON |

+--------------------------+-----------+

解决方法:

这是一个非常棘手的问题,因为你超越了InnoDB的当前限制.

你的问题绝不是唯一的.这已在此处讨论过

我还会查看您当前使用的字符集.

Bill Karwin在他的最后一段中说得最好

I also have to comment that I’ve never seen a well-designed table exceed the row size limit. It’s a strong “code smell” that you’re violating the repeating groups condition of First Normal Form.

您将不得不定义更好的设计.没有商业理由可以证明这一点.为什么?

我亲眼目睹了这一点

In my earlier days as a developer, I worked at a company back in 1995 where DB2 was the main RDBMS. The company had a single table that had 270 columns, dozens of indexes, and had performance issues retrieving data. They contacted IBM and had consultants look over the architecture of their system, including this one monolithic table. The company was told “If you do not normalize this table in the next 2 years, DB2 will fail on queries doing Stage2 Processing (any queries requiring sorting on non-indexed columns).” This was told to a multi-trillion dollar company, to normalize a 270 column table. How much more so a 2000 column table.

一个包含300个TEXT列的表要求同样的麻烦.

总结:Bill Karwin之前说过,我同意:重新设计表格.这肯定会限制行长度问题.

标签:linux,mysql,innodb,mysql-5-5

来源: https://codeday.me/bug/20190805/1592920.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值