Maximum Number of Columns per Table

As you may know, a database table in YugabyteDB is made up of columns and rows.

There is no theoretical maximum number of rows that a table can store because of YugabyteDB’s horizontal scale out capability, but is there a limit to the number of columns in a table?

Let’s check by trying to create a table with 100,000 columns:

				
					yugabyte=# \! ./bin/ysqlsh -h 192.168.56.110 -Atc "SELECT 'DROP TABLE test_table; CREATE TABLE test_table (' UNION ALL SELECT 'col' || generate_series || CASE WHEN generate_series <100000 THEN ' INT,' ELSE ' INT);' END FROM generate_series(1, 100000);" | ./bin/ysqlsh -h 192.168.56.110
DROP TABLE
ERROR:  tables can have at most 1600 column
				
			

As you can see, there is a limit of 1,600 columns per table.

Have Fun!