sql server - MySQL error code 1005 Can't create table (errno150) - (again) - in all the foreign keys -


background:-

yesterday creating small database practice, , created 9 tables, , got error in create table statement of 1 of them. question located here. thankfully told alternative way creating table without foreign key , use alter table statement add foreign key constraint, , worked.

today creating database, , getting error in tables contain foreign keys. have tried alternative way of creating table , adding foreign keys alter table statement. doesn't seem help.

my research:-

i know question has been been addressed before on website, have tried solutions on this, this page, except adding indexes because firstly, don't need them in such small database (second point in first answer), , secondly don't know them , want keep simple. none of answers helped.

moreover, mentioned here, " if error message refers error 150, table creation failed because foreign key constraint not correctly formed. "

please tell me what's wrong foreign key constraint.

create table table1 (     table1_id int(11) auto_increment,     name varchar(5000),     code varchar(5000),     color varchar(5000),     primary key (table1_id) ) engine=innodb default charset=utf8;  create table table2( -- error code 1005 can t create table errno 150 mysql     table2_id int(11) auto_increment,     date date,     start_time time,     end_time time,     table1_id int(11) comment 'fk table1',     primary key (table2_id),     foreign key (table1_id)         references table1(table1_id)          on update cascade on delete restrict ) engine=innodb default charset=utf8; 

so hints/tips on this?


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -