2016-11-21 32 views
0

语法错误: -接收的语法错误,这个SQL代码

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

在MySQL中有一个名为身份无关,而是有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 

); 
1

u必须声明主键一次

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)); 
+0

我还需要吗? CONSTRAINT CustomerPK PRIMARY KEY(CustomerID) –

+0

他们没有什么可以使用任何其他的东西只是写PRIMARY KEY(customerID)@RhettClaypool –

+0

现在我们删除了错误吗?@RhettClaypool –