开发者

error syntax -mysql

when i try to insert this code i get an mysql error syntax

CR开发者_Go百科EATE TABLE 'data'
(
'id' int primary key auto_increment,
'data' varchar(50),
'weight' int(2),
)

#1064 - 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 ''data'

what is the error?!

thanks


You have an extra comma after the weight line:

'weight' int(2),
               ^--- here

as well, you don't enclose field names in quotes, so the correct syntax for the whole thing is:

CREATE TABLE data (
    id int primary key auto_increment,
    data varchar(50),
    weight int(2)
);


You have an erroneous trailing comma, and the way to delimit fieldnames is with the backtick, not single-quote.

CREATE TABLE `data` (
    `id`     INT PRIMARY KEY AUTO_INCREMENT,
    `data`   VARCHAR(50),
    `weight` INT(2)
);


You're using the wrong type of quotes. MySQL's literal-name quoting uses a backtick, not an on ordinary apostrophe. In fact, you don't really need to quote those names at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜