Is there a limit to the number of columns a table can have?

Question

Is there a limit to the number of columns a table can have?

Answer

Yes, there is a limit to the number of columns a table can have.

In SQLite in particular, the upper bound for this number of columns is stored in a parameter called SQLITE_MAX_COLUMN, and by default, it is set to 2000 columns.

This value can be changed during compile time and can be set up to a maximum value of 32767. However, realistically, your tables will probably never need these many columns, but, it is available as an option if ever needed.

8 Likes

Why the number specifically?

4 Likes

Since computers store data in binary as either 1 or 0, I believe the number comes from 2^15 which is 32768 but since computers start counting from 0, it’s one less - the maximum size than can be held in 16 bit.

13 Likes

What about other RDBMSs? Are there any differences there?