所以我有这个:
CREATE TABLE activeSessions (
id VARCHAR NOT NULL UNIQUE,
claimtime int,
mp FLOAT
);
当我将其放入数据库中时,就会出现:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL UNIQUE,
claimtime int,
mp FLOAT
)' at line 2
我该如何解决?
答案 0 :(得分:2)
您需要在列声明之后指定约束:
CREATE TABLE activeSessions (
id VARCHAR(10) NOT NULL,
claimtime int,
mp FLOAT,
UNIQUE(id)
);
记住要为VARCHAR列提供一个INT值。