0

Syntax error:-

CREATE TABLE CUSTOMER (
CustomerID        Int    NOT NULL IDENTITY(1,1) PRIMARY KEY, 
CustomerName      Char(25)                      NOT NULL,
CustomerDeliveryAddress  Char(25)               NOT NULL,                                       
CustomerPhone            Char (10)              NOT NULL,
CustomerBillingAddress   Char(25)               NOT NULL,
CustomerCreditCard       Int                    NOT NULL,
CONSTRAINT  CustomerPK          PRIMARY KEY(CustomerID)
);

2 Answers 2

2

In mysql there is nothing named identity, instead there is AUTO_INCREMENT

CREATE TABLE CUSTOMER (
CustomerID        INT NOT NULL AUTO_INCREMENT  PRIMARY KEY, 
CustomerName      Char(25)                      NOT NULL,
CustomerDeliveryAddress  Char(25)               NOT NULL,                                       
CustomerPhone            Char (10)              NOT NULL,
CustomerBillingAddress   Char(25)               NOT NULL,
CustomerCreditCard       Int                    NOT NULL

);
Sign up to request clarification or add additional context in comments.

Comments

1

u have to declare primary key only once

CREATE TABLE CUSTOMER (
CustomerID        INT NOT NULL AUTO_INCREMENT,
CustomerName      Char(25)                      NOT NULL,
CustomerDeliveryAddress  Char(25)               NOT NULL,
CustomerPhone            Char (10)              NOT NULL,
CustomerBillingAddress   Char(25)               NOT NULL,
CustomerCreditCard       Int                    NOT NULL,
PRIMARY KEY(CustomerID));

2 Comments

Do I still need this? CONSTRAINT CustomerPK PRIMARY KEY(CustomerID)
their is nothing to use any other thing just write PRIMARY KEY(customerID)@RhettClaypool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.