我在phpmyadmin中一直收到1064错误

时间:2022-03-24 21:47:05

I am trying to create a table in phpmyadmin with the following

我正在尝试使用以下内容在phpmyadmin中创建一个表

SQL : 

CREATE TABLE `umOrder`.`Bill` (
    `Id` INT(5) NOT NULL AUTO_INCREMENT ,
    `userID` VARCHAR(255) NOT NULL ,
    `product` VARCHAR(255) NOT NULL ,
    `quantity` INT(3) NOT NULL ,
    `price` DOUBLE(5) NOT NULL , 
    `date` VARCHAR(255) NOT NULL ,
    PRIMARY KEY (`Id`(5))
  ) ENGINE = MEMORY;

But keep getting this error :

但不断收到此错误:

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 , date VARCHAR(255) NOT NULL , PRIMARY KEY (Id(5))) ENGINE =' at line 1

I don't really understand what the error mean ? any Idea ?

我真的不明白错误是什么意思?任何想法 ?

2 个解决方案

#1


1  

The key(id(5)) is suspect. But you have another error as well: double doesn't take a length argument.

密钥(id(5))是可疑的。但是你也有另一个错误:double不接受长度参数。

The following should work:

以下应该有效:

CREATE TABLE `Bill` (
    `Id` INT(5) NOT NULL AUTO_INCREMENT ,
    `userID` VARCHAR(255) NOT NULL ,
    `product` VARCHAR(255) NOT NULL ,
    `quantity` INT(3) NOT NULL ,
    `price` DOUBLE NOT NULL , 
    `date` VARCHAR(255) NOT NULL ,
    PRIMARY KEY (`Id`)
  ) ENGINE = MEMORY;

Here is a SQL Fiddle.

这是一个SQL小提琴。

Note: I don't think it is helpful to put length arguments after numeric types (other than decimal/numeric). You might want to consider removing all of them.

注意:我认为在数字类型(十进制/数字除外)之后放置长度参数是没有用的。您可能需要考虑删除所有这些内容。

#2


1  

You'll want to assign the decimal for the double:

您需要为double分配小数:

CREATE TABLE `umOrder`.`Bill` (
    `Id` INT (5) NOT NULL AUTO_INCREMENT,
    `userID` VARCHAR (255) NOT NULL,
    `product` VARCHAR (255) NOT NULL,
    `quantity` INT (3) NOT NULL,
    `price` DOUBLE (5,2) NOT NULL,
    `date` VARCHAR (255) NOT NULL,
    PRIMARY KEY (`Id`)
) ENGINE = MEMORY;

#1


1  

The key(id(5)) is suspect. But you have another error as well: double doesn't take a length argument.

密钥(id(5))是可疑的。但是你也有另一个错误:double不接受长度参数。

The following should work:

以下应该有效:

CREATE TABLE `Bill` (
    `Id` INT(5) NOT NULL AUTO_INCREMENT ,
    `userID` VARCHAR(255) NOT NULL ,
    `product` VARCHAR(255) NOT NULL ,
    `quantity` INT(3) NOT NULL ,
    `price` DOUBLE NOT NULL , 
    `date` VARCHAR(255) NOT NULL ,
    PRIMARY KEY (`Id`)
  ) ENGINE = MEMORY;

Here is a SQL Fiddle.

这是一个SQL小提琴。

Note: I don't think it is helpful to put length arguments after numeric types (other than decimal/numeric). You might want to consider removing all of them.

注意:我认为在数字类型(十进制/数字除外)之后放置长度参数是没有用的。您可能需要考虑删除所有这些内容。

#2


1  

You'll want to assign the decimal for the double:

您需要为double分配小数:

CREATE TABLE `umOrder`.`Bill` (
    `Id` INT (5) NOT NULL AUTO_INCREMENT,
    `userID` VARCHAR (255) NOT NULL,
    `product` VARCHAR (255) NOT NULL,
    `quantity` INT (3) NOT NULL,
    `price` DOUBLE (5,2) NOT NULL,
    `date` VARCHAR (255) NOT NULL,
    PRIMARY KEY (`Id`)
) ENGINE = MEMORY;