Mofeed Shahin <[EMAIL PROTECTED]> wrote: > On Mon, 15 Dec 2003 12:42 pm, Paul DuBois wrote: >> At 11:09 +1030 12/15/03, Mofeed Shahin wrote: >> >I'm trying to create a bunch of tables in MySQL. I'm having problems >> > creating the following table : >> > >> >CREATE TABLE foo( >> > ID INT PRIMARY KEY, >> > note VARCHAR(50), >> > FOO_ID INT, >> > FOREIGN KEY (FOO_ID) REFERENCES foo(ID) >> >) TYPE=INNODB; >> > >> >The error I get is the following : >> >ERROR 1005: Can't create table './moftest/foo.frm' (errno: 150) >> > >> >I found out that errno 150 means that it didn't like the Foreign key >> >constraint. >> > >> >Does MySQL not support this type of Foreign Key constraint ? >> >> If does. However, a foreign key must be indexed, and you have declared >> no index on FOO_ID. Try this: >> >> CREATE TABLE foo( >> ID INT PRIMARY KEY, >> note VARCHAR(50), >> FOO_ID INT, >> INDEX (FOO_ID), >> FOREIGN KEY (FOO_ID) REFERENCES foo(ID) >> ) TYPE=INNODB; > > Thanks, but I just did, and I got the same error message. >
Paul's example works fine for me. What version of MySQL do you use? -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]