0

While working on a project developed with Laravel 5.8 I wanted to create a database (table migration) with a table of more than 100 columns. So I came across this error:

Illuminate \ Database \ QueryException: SQLSTATE [42000]: Syntax error or access violation: 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

As I understand it, MySql cannot contain as many columns in a table.

My question is, therefore: Is there a solution to this problem?

Saliou MBALO
  • 169
  • 1
  • 11
  • 1
    There are a few similar/related questions answered here already: https://stackoverflow.com/questions/10349361/mysql-how-to-workaround-the-row-size-limit-of-66-kbytes however, in your case, you seem to just have a lot of fields. I see no reason for a table to have that many fields. I would suggest analyzing your data and break related fields out into child tables. It makes it easier to analyze data later, and prevents having to query the data in its entirety every time you only need a subset of data related to the primary record. – gmiley Jul 07 '20 at 15:06
  • 1
    Actually, it's not about the number of columns... But, the size of the columns... – STA Jul 07 '20 at 15:09
  • 1
    What are columns datatypes? Maybe you can to shrink row size using compact field types – Slava Rozhnev Jul 07 '20 at 18:26

1 Answers1

2

Instead of using a table with a large number of columns. You can use many table and reduce the number of columns. You just have to link the table using primary and foreign keys

ganiular
  • 331
  • 2
  • 8