《MYSQL數據庫更新text字段時出現Row size too large報錯應付措施》要點:
本文介紹了MYSQL數據庫更新text字段時出現Row size too large報錯應付措施,希望對您有用。如果有疑問,可以聯系我們。
起因:
團購開發申報說更新時出錯.
更新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中優化了報錯提示.
維易PHP培訓學院每天發布《MYSQL數據庫更新text字段時出現Row size too large報錯應付措施》等實戰技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培養人才。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/14151.html