Foreign Key Error on MySQL CREATE TABLE statement (err: 150)?

You don't reference to a field, only a table, which is incorrect foreign key (yyy_no) references foo_ent(yyy_no) And according to your error number, the MySQL documentation also states If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier. If these are not satisfied, MySQL returns error number 1005 and refers to error 150 in the error message dev.mysql.com/doc/refman/5.5/en/innodb-f....

You don't reference to a field, only a table, which is incorrect. ... foreign key (yyy_no) references foo_ent(yyy_no) And according to your error number, the MySQL documentation also states; If you re-create a table that was dropped, it must have a definition that conforms to the foreign key constraints referencing it. It must have the right column names and types, and it must have indexes on the referenced keys, as stated earlier.

If these are not satisfied, MySQL returns error number 1005 and refers to error 150 in the error message. dev.mysql.com/doc/refman/5.5/en/innodb-f....

Ah, I thought at one time you only had to specify the field of the table when the field names were different between the two. Maybe they changed this or I am incorrect. Thanks!

– jparanich Mar 18 at 21:31.

You should provide the name of the referenced column explicitly: CREATE TABLE cat_ent ( some_item INTEGER NOT NULL, yyy_non VARCHAR(80), apple DECIMAL(6,2), PRIMARY KEY (some_item), FOREIGN KEY (yyy_non) REFERENCES foo_ent(yyy_no) ).

Consider rewriting your FOREIGN KEY declaration to explicitly list the column in foo_ent that you want to key on: CREATE TABLE cat_ent(some_item INTEGER, yyy_no VARCHAR(80), apple DECIMAL(6,2), PRIMARY KEY (some_item), FOREIGN KEY (yyy_no) REFERENCES foo_ent(yyy_no)) ENGINE=InnoDB; works for me.

I feel I've tried everything possible on a very simple pair of create table statements. The types match, I tried using ENGINE = InnoDB, etc and am stumped why I'm getting the foreign key error. I've been away from SQL for some time, so this is probably an easy one.

Sorry about the poor variable names, safe to over-write company stuff.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions