MySQL创建不起作用错误1064

时间:2013-05-25 18:19:42

标签: mysql sql database

我有这个问题:

CREATE TABLE
    `rooms` (
    `roomname` VARCHAR NOT NULL PRIMARY KEY,
    `price` DOUBLE NOT NULL
)
ENGINE = MyISAM";

但它不起作用我收到此错误:

#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 'NOT NULL PRIMARY KEY, `price` DOUBLE NOT NULL ) ENGINE = MyISAM"' at line 3

这里有什么问题?

2 个答案:

答案 0 :(得分:3)

CREATE TABLE
    `rooms` (
    `roomname` VARCHAR(20) NOT NULL PRIMARY KEY,
    `price` DOUBLE NOT NULL
)
ENGINE = MyISAM";

您需要指定长度

答案 1 :(得分:0)

是的,您需要指定VARCHAR(长度)。长度决定了您可以用作房间名称的字符数。