程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 更新text字段時出現Row size too large報錯應付措施

更新text字段時出現Row size too large報錯應付措施

編輯: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中優化了報錯提示。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved