简体   繁体   English

sql错误#1064不知道这是什么错误

[英]sql error#1064 no idea what is wrong here

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE Products( Category VARCHAR(30), Item VARCHAR(30),PRIMARY KEY, Pr' at line 2 检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第2行的“创建表产品(类别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;
CREATE TABLE Products(
Category VARCHAR(30),
Item VARCHAR(30),PRIMARY KEY, <-- The comma is your problem
Price DECIMAL(5,2),
Quantity INT
) ENGINE=InnoDB;

To assign PK to a column, it should be: 要将PK分配给列,应为:

CREATE TABLE Products(
Category VARCHAR(30),
Item VARCHAR(30) PRIMARY KEY,
Price DECIMAL(5,2),
Quantity INT
) ENGINE=InnoDB;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM