What is the maximum length of a table name in MySQL?

The maximum length of a table name is 64 characters long according to MySQl version 8.0.12.

Check your installed MySQL version.

mysql> select version();

The following is the output.

| version() |
| 8.0.12    |
1 row in set (0.03 sec)

We can check the maximum length of the table name at the time of creating it. If we give more than 64 characters, then it will not create a table and an error is thrown.

Creating a table which has more than 64 characters of table name.

mysql> create table tableNameDemotableableNameDemotableableNameDemotableableNameDemotable
   -> (
   -> id int
   -> );
ERROR 1059 (42000): Identifier name 'tableNameDemotableableNameDemotableableNameDemotableableNameDemotable' is too long

In the above, we get an error that the identifier name (yourTableName) is too long.

To check if it will work for 64 characters or below −

mysql> create table Demo
   -> (
   -> id int
   -> );
Query OK, 0 rows affected (0.46 sec)

Yes, less than 64 characters for a table name works correctly.

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started