我有这个问题:
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
这里有什么问题?
答案 0 :(得分:3)
CREATE TABLE
`rooms` (
`roomname` VARCHAR(20) NOT NULL PRIMARY KEY,
`price` DOUBLE NOT NULL
)
ENGINE = MyISAM";
您需要指定长度
答案 1 :(得分:0)
是的,您需要指定VARCHAR(长度)。长度决定了您可以用作房间名称的字符数。