- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements