您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第2行的'CREATE TABLE产品(类别VARCHAR(30),项目VARCHAR(30),PRIMARY KEY,Pr'附近使用正确的语法
CREATE TABLE Products(
Category VARCHAR(30),
Item VARCHAR(30) PRIMARY KEY,
Price DECIMAL(5,2),
Quantity INT
) ENGINE=InnoDB;
答案 0 :(得分:4)
CREATE TABLE Products(
Category VARCHAR(30),
Item VARCHAR(30),PRIMARY KEY, <-- The comma is your problem
Price DECIMAL(5,2),
Quantity INT
) ENGINE=InnoDB;
要将PK分配给列,它应该是:
CREATE TABLE Products(
Category VARCHAR(30),
Item VARCHAR(30) PRIMARY KEY,
Price DECIMAL(5,2),
Quantity INT
) ENGINE=InnoDB;