Hi All,

Im altering a number of table from MyISAM to innoDb and adding foreign keys.

The alteration of the table type works.
Adding the row as an index works.
Adding the foreign key fails, generating the error:

 alter table project add FOREIGN KEY (company_id)  references company (id)
 [mySQL] ERROR 1216: Cannot add or update a child row: a foreign key
constraint fails

CREATE TABLE company (
  id int NOT NULL auto_increment,
  PRIMARY KEY  (id)
) 

CREATE TABLE project (
  id int NOT NULL auto_increment,
  company_id int default NULL,
) 


Would anyone have any idea what causing this error?

Thanks

Terry

Terry Spencer
Haigh Consultancy Services
+44 (0)2073007329
www.haigh-cs.co.uk


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to