更新text字段时出现Row size too large报错应付措施
个人建议:表的text字段很多建议建表时加上 row_format = dynamic当然,回过头来MySQL的报错也是有误导性的,感兴趣的你可以参考下本文
起因:团购开发报告说更新时出错。
更新SQL如下:
代码如下:
UPDATE table_name d SET d.column_name='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
WHERE d.ID=100976;
报错信息如下:
Error Code : 1118
Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
疑惑:
更新字段只涉及 column_name字段,且该字段是TEXT类型。
个人之前理解是:
TEXT的内容在 Dynamic的table format下是存在off-page中的,不会占用row size的计算。
Barracuda 对应row_format ( dynamic, compress) ,其中dynamic下text的所有内容都是off-page存放的 (点击查看)
Antelope 对应row_format (compact, redundant),其中compact下的text是存786B在row中,超过部分存在off-page
而服务器配置是 innodb_file_format = Barracuda
照理说所有table用的都是 dynamic 结构。
但是! 原因如下,摘自文档:
To preserve compatibility with those prior versions, tables created with the InnoDB Plugin use the prefix format, unless one of ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED is specified (or implied) on the CREATE TABLE command.
也就是说,建表时不显示指定 row_format = dynamic ,即使 innodb_file_format = Barracuda 表的row-format还是 compact
所以总结为一句话就是:如果某个表的text字段很多建议建表时加上 row_format = dynamic
当然,回过头来MySQL的报错也是有误导性的,bug库中也对confirm了这个bug(点击查看),并在5.1.61中优化了报错提示。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
