mysql数据库创建删除带横杠的数据库名

mysql> create database d-d;

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 '-d' at line 1

1064报错:该错误一般出现在表名或者字段名设计过程中出现了mysql关键字导致的。问题确定是数据库名字的错误,我把横杠去掉以后就可以。

尝试:

create database [d-d];

create database 'd-d';

create database ”d-d“;

create database d\-d;

均报错:
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 '[d-d]' at line 1

扫描二维码关注公众号,回复: 3210747 查看本文章

解决:create database `d-d`;    加反引号

mysql> create database `d-d`;
Query OK, 1 row affected (0.00 sec)

猜你喜欢

转载自www.cnblogs.com/weifeng1463/p/9652912.html
今日推荐