mysql – 如何在列名中使用特殊字符
作者:互联网
这是我失败的MySQL代码:
CREATE TABLE product (
id int NOT NULL AUTO_INCREMENT,
'item-name' VARCHAR(255) NOT NULL,
'item-description' TEXT,
'listing-id' VARCHAR(50),
PRIMARY KEY (id)
)
错误是:
Error creating table: 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
‘item-name’ VARCHAR(255) NOT NULL, ‘item-description’ TEXT, ‘listing-id” at line 3
文档说使用引号……有什么问题?
解决方法:
需要使用`而不是’:
CREATE TABLE product (
id int NOT NULL AUTO_INCREMENT,
`item-name` VARCHAR(255) NOT NULL,
`item-description` TEXT,
`listing-id` VARCHAR(50),
PRIMARY KEY (id)
)
标签:create-table,mysql 来源: https://codeday.me/bug/20190725/1533645.html