# [EMAIL PROTECTED] / 2003-06-25 14:03:17 +0100: > 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, > )
http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]