无法创建表

时间:2014-11-26 13:35:47

标签: mysql sql

我正在使用此SQL查询来创建表,但确实在我的REFRENCES AT第13行中出错。这是我的查询

CREATE TABLE ITEM (
    ID INT NOT NULL, 
    TYPE VARCHAR (32) NOT NULL, 
    DESCRIPTION VARCHAR (64) NOT NULL,
    SIZE FLOAT NOT NULL, 
    SIZE_TYPE VARCHAR (4) NOT NULL,
    MANUFACTURE VARCHAR (16) NOT NULL, 
    SECTION VARCHAR (16) NOT NULL, 
    PRICE FLOAT NOT NULL, 
    LEVEL INT(1) NOT NULL, 
    AISLE_ID INT(11) NOT NULL,
    PRIMARY KEY (ID), 
      FOREIGN KEY (AISLE_ID), 
    REFERENCES aisle(AISLE_ID)
    ); 

2 个答案:

答案 0 :(得分:0)

CREATE TABLE ITEM (
ID INT NOT NULL, 
TYPE VARCHAR (32) NOT NULL, 
DESCRIPTION VARCHAR (64) NOT NULL,
SIZE FLOAT NOT NULL, 
SIZE_TYPE VARCHAR (4) NOT NULL,
MANUFACTURE VARCHAR (16) NOT NULL, 
SECTION VARCHAR (16) NOT NULL, 
PRICE FLOAT NOT NULL, 
LEVEL INT NOT NULL, 
AISLE_ID INT NOT NULL

PRIMARY KEY (ID) ,
  FOREIGN KEY (AISLE_ID)   REFERENCES aisle(AISLE_ID)
) 

答案 1 :(得分:0)

FOREIGN KEY (AISLE_ID), 
REFERENCES aisle(AISLE_ID)

错了,应该是:

FOREIGN KEY (AISLE_ID) REFERENCES aisle(AISLE_ID)