我们可以使用 MySQL 创建带有数字名称的数据库吗?

mysqlmysqli database更新于 2024/8/10 17:48:17

您无法创建带有数字名称的数据库,如下所示 −

mysql> create database 1233;

这将产生以下输出 −

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

要创建具有数字名称的数据库,您需要在数据库名称周围使用反引号−

create database yourDatabaseName;

让我们实现上述语法 −

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

现在您可以切换到同一个数据库 −

mysql> use `1233`;
Database changed


相关文章


有用资源