简体   繁体   中英

MySql issues using ENGINE = INNODB

So first things first, below is my code. When I run this on my school's mysql server I get back ERROR 1005 (HY000). Although this error ONLY happens for the customers, orders, and odetails tables. I do get a few warnings back. From the research I have done this is being caused by me implementing innodb incorrectly. Any help would be much appreciated, especially since this is only one of the starting steps for this assignment.

drop table IF EXISTS employees;
drop table IF EXISTS parts;
drop table IF EXISTS customers;
drop table IF EXISTS orders;
drop table IF EXISTS odetails;
drop table IF EXISTS zipcodes;

create table employees
    (eno        numeric(4,0),
     ename      varchar(15),
     zip        numeric(5,0),
     hdate      date default null,
     primary key (eno),
     foreign key (zip) references zipcodes (zip)
    )ENGINE=InooDB;

create table parts
    (pno        numeric(5,0),
     pname      varchar(30),
     qoh        numeric(3,0),
     price      numeric(10,2),
     level      numeric(2,0),
     primary key (pno)
    )ENGINE=InnoDB;

create table customers
    (cno        numeric(4,0),
     cname      varchar(15),
     street     varchar(30),
     zip        numeric(5,0),
     phone      varchar(12),
     primary key (cno),
     foreign key (zip) references zipcodes (zip))
     ENGINE=InnoDB;

create table orders
    (ono        numeric(4,0),
     cno        numeric(4,0),
     eno        numeric(4,0),
     received   date default null,
     shipped    date default null,
     primary key (ono),
     foreign key (cno) references customers (cno),
     foreign key (eno) references employees (eno)
    )ENGINE=InnoDB;

create table odetails
    (ono        numeric(4,0),
     pno        numeric(5,0),
     qty        numeric(1,0),
     primary key (ono, pno),
     foreign key (ono) references orders (ono),
     foreign key (pno) references parts (pno)
    )ENGINE=InnoDB;

create table zipcodes
    (zip        numeric(5,0),
     city       varchar(15),
     primary key (zip)
    )ENGINE=InnoDB;

1005 -- Declare the tables in the correct order based on the FOREIGN KEYs . For example, do zipcodes first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM