Can we create a database with a numeric name with MySQL?

You cannot create database with numeric name as shown below −

mysql> create database 1233;

This will produce the following output −

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near '1233' at line 1

To create a database with numeric name, you need to use backticks around the database name −

create database yourDatabaseName;

Let us implement the above syntax −

mysql> create database `1233`;
Query OK, 1 row affected (0.20 sec)

Now you can switch to the same database −

mysql> use `1233`;
Database changed

Updated on: 16-Dec-2019


Kickstart Your Career

Get certified by completing the course

Get Started