Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Error (1118):Row size too large. The maximum row size for the used table type, not counting BLOBs

Tags:

mysql

I have create one MySQL database table. I have to create 195 columns in one table. I have to give the data types of 190 columns is VARCHAR and 5 columns data type are text. Each columns have length 500.

Actually I want to create 1000 columns in one database table and I want to use data type is VARCHAR in each table columns. Now when I am creating new columns in database table. I am getting this error:

SQL Error (1118):Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

like image 538
Junaid Usmani Avatar asked May 03 '15 19:05

Junaid Usmani


2 Answers

You database design is flawed.

Maximum row size with MySQL = 65,535 bytes.

Assuming 1 byte per character 500 X 1000 = 50,000 bytes per row which is approaching 65,535.

For VARCHAR(L) using latin1 1 byte per column is required to hold length L so now we are at 501,000.

For a VARCHAR column that stores multibyte characters, the effective maximum number of characters is less. For example, utf8 characters can require up to three bytes per character.

500 X 4 X 1000 = 2,000,000 bytes (3 per char + 1 for length)

For more information MySQL Documentation MySQL Maximum Number of Columns AND Data Type Storage Requirements.

I suggest you learn more about database design before proceeding.

like image 93
david strachan Avatar answered Sep 22 '22 10:09

david strachan


Run SQL query/queries on database

SET GLOBAL innodb_strict_mode=OFF;
like image 40
GMKHussain Avatar answered Sep 26 '22 10:09

GMKHussain