user3362580
user3362580

Reputation: 31

Im getting an error when creating my database (#1064)

I was trying to create a database using phpmyadmin but I keep on getting error

#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,First Name VARCHAR(30) NOT NULL,Last Name VARCHAR(30) NOT' at line 3

Im using Tomcat version 8.0. Below is the query I am Executing

CREATE TABLE `cs485_lab5`.`Orders` (
    `Item Number` VARCHAR(20) NOT NULL, 
    `Price` DOUBLE(10) NOT NULL, 
    `First Name` VARCHAR(30) NOT NULL, 
    `Last Name` VARCHAR(30) NOT NULL, 
    `Shipping Address` VARCHAR(50) NOT NULL, 
    `Credit Card` VARCHAR(20) NOT NULL, 
    `CCN` INT(16) NOT NULL, 
    PRIMARY KEY (`Credit Card`)
) ENGINE = InnoDB;

Upvotes: 1

Views: 55

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269773

Don't specify a length for DOUBLE. Also, if you are designing the table, don't put spaces in the column names. Use names that don't need escaping. Having to use escape characters just clutters up queries unnecessarily.

So:

CREATE TABLE Orders (
    `ItemNumber` VARCHAR(20) NOT NULL, 
    `Price` DOUBLE NOT NULL, 
    `FirstName` VARCHAR(30) NOT NULL, 
    `LastName` VARCHAR(30) NOT NULL, 
    `ShippingAddress` VARCHAR(50) NOT NULL, 
    `CreditCard` VARCHAR(20) NOT NULL, 
    `CCN` INT(16) NOT NULL, 
    PRIMARY KEY (`CreditCard`)
) ENGINE = InnoDB;

Here is a SQL Fiddle.

Upvotes: 2

Related Questions