天天看點

MySQL新增字段報錯:ERROR 1118 -- Row size too large. The maximum row size for the used table type

MySQL新增字段報錯:ERROR 1118 – Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535.

錯誤資訊

ERROR 1118 : Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535.

You have to change some columns to TEXT or BLOBs

錯誤原因

MySQL建表時有一個單行最大限制長度限定:一張表中所有字段設定的位元組數總和不大于65535位元組

注意點一:單個字段大小超過65535轉換為text

注意點二:其餘字段總和不超過65535位元組(不包括BLOB/TEXT)

注意點三:資料庫使用UTF-8編碼,一個字元=三個位元組大小

報錯舉例:資料庫存在10個varchar字段,每個大小為3000 則資料庫單行目前計算長度為 3000 * 10 * 3 = 90000 > 65535 則

解決辦法:将資料庫表大字段類型設定為TEXT,或者将部分可以減小長度的長度調小至總和小于65535