如何在MySQL列名称中使用特殊字符? [英] How to use special characters in MySQL column names?

查看:254
本文介绍了如何在MySQL列名称中使用特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我失败的MySQL代码:

Here is my failing MySQL code:

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)
        )

错误是:

错误创建表:您的SQL语法有错误;查看手册 对应于您的MySQL服务器版本,以获取在near
上使用的正确语法 第3行的'item-name'VARCHAR(255)NOT NULL,'item-description'TEXT,'listing-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

文档说要使用引号...怎么了?

The documentation says to use quotes... What is wrong?

推荐答案

使用`代替':

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)
    )

这篇关于如何在MySQL列名称中使用特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆