[MySQL database principle] The maximum number of columns and rows of MySQL tables

insert image description here

The maximum number of columns and rows of a MySQL table is affected by many factors, including the MySQL version, operating system, hardware configuration, and table type. The following are the column and row limits for some common MySQL tables:

Column limit:
MySQL 5.7 and earlier versions of MyISAM and InnoDB tables have a limit of 4096 columns. MySQL 8.0 and newer have a column limit of 1017 for MyISAM and InnoDB tables.

Example: Create a MyISAM table and try to add more than 4096 columns, you will get the following error message:

ERROR 1117 (HY000): Too many columns

Row limit:
MySQL's row limit depends on the type of table and the limitations of the operating system. For InnoDB tables, the number of rows is limited by the tablespace. By default, InnoDB tables have a maximum row count of approximately 5 billion rows. However, if you increase the size of the InnoDB tablespace, you can also increase the maximum number of rows. Also, operating system file size limitations can affect the maximum number of rows for a table.

Example: Create an InnoDB table and try to insert data that exceeds the maximum number of rows, you will get the following error message:

ERROR 1114 (HY000): The table 'table_name' is full

The maximum limit on the number of columns and rows for a MySQL table is affected by several factors. The specific situation needs to be evaluated and adjusted according to the actual situation.

Guess you like

Origin blog.csdn.net/weixin_41194129/article/details/130082224
Recommended