mysql错误1064找不到错误

时间:2015-03-13 19:42:59

标签: mysql

我在'FOREIGN KEY(zip)附近找不到错误, 并且也不确定为什么它不能创建订单,并且详细说明, 我怀疑它与主键组成有关 两个外键。

CREATE TABLE zipcodes
    (zip            NUMERIC(5,0), 
     city       VARCHAR(20),

     PRIMARY KEY (zip)

    ) ENGINE = InnoDB;

CREATE TABLE employees
    (eno        VARCHAR(10),
     ename      VARCHAR(20),
     zip        NUMERIC(5,0),
    hdate     date, 
     PRIMARY KEY (eno,
     FOREIGN KEY (zip) REFERENCES zipcodes (zip)
    ) ENGINE = InnoDB;

CREATE TABLE parts
    (pno        VARCHAR(6), 
     pname      VARCHAR(25), 
     qoh        NUMERIC(3,0),
    price           NUMERIC (6,2),
    levels          NUMERIC (2,0),


     primary key (pno)

    ) ENGINE = InnoDB;

CREATE TABLE customers
    (cno        VARCHAR(5), 
     cname      VARCHAR(20), 
     street     VARCHAR(30),
     zip        NUMERIC(5,0),
    phone       VARCHAR(14),
     PRIMARY KEY (cno),
     FOREIGN KEY (zip) REFERENCES zipcodes (zip)

    ) ENGINE = InnoDB;

CREATE TABLE orders
    (ono            VARCHAR(5), 
     cno            VARCHAR(5),
     eno            VARCHAR(10),
     received       DATE, 
     shipped        DATE,
     PRIMARY KEY (ono),
     FOREIGN KEY (cno) REFERENCES customers (cno),
    FOREIGN KEY (eno) REFERENCES employees (eno)


    ) ENGINE = InnoDB;

CREATE TABLE odetails
    (ono        VARCHAR(5),
    pno         VARCHAR(6),
    qty         VARCHAR(3),

     PRIMARY KEY (ono,pno),
     FOREIGN KEY (ono) REFERENCES orders (ono),
    FOREIGN KEY (pno) REFERENCES parts (pno)


    ) ENGINE = InnoDB;

0 个答案:

没有答案