简体   繁体   English

表创建语句中的MySQL语法错误

[英]MySQL Syntax Error in table creation statement

This question is very straight forward. 这个问题很简单。 I have this MySQL error that I haven't been able to figure out, and I need some help finding it. 我有一个我无法弄清的MySQL错误,我需要一些帮助来找到它。

The full error: 完整错误:

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near ' release date NOT NULL, downloads INT NOT NULL DEFAULT '0', f ' at line 6 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在' 发布日期NOT NULL附近使用在第6行下载INT NOT NULL DEFAULT'0',f '

The SQLStatement: SQLStatement:

CREATE TABLE IF NOT EXISTS sdm_downloads
    (
        id INT NOT NULL AUTO_INCREMENT,
        project INT NOT NULL DEFAULT '0',
        name VARCHAR(40) NOT NULL,
        release date NOT NULL,
        downloads INT NOT NULL DEFAULT '0',
        filename varchar(40) NOT NULL,
        filesize varchar(40) NOT NULL,
        PRIMARY KEY(id)
    )

Thanks in advance for any, and all help. 在此先感谢您提供的所有帮助。

You need to escape reserved words like release with backticks 您需要转义保留字,例如使用反引号release

CREATE TABLE IF NOT EXISTS sdm_downloads
(
    id INT NOT NULL AUTO_INCREMENT,
    project INT NOT NULL DEFAULT 0,
    name VARCHAR(40) NOT NULL,
    `release` date NOT NULL,
    downloads INT NOT NULL DEFAULT 0,
    filename varchar(40) NOT NULL,
    filesize varchar(40) NOT NULL,
    PRIMARY KEY(id)
)

SQLFiddle demo SQLFiddle演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM