ben0it24 Posted March 24, 2010 Share Posted March 24, 2010 CREATE TABLE `pmd_machinery` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) DEFAULT NULL, `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `domain_ID` (`domain_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=95 ; CREATE TABLE `pmd_domains` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(50) DEFAULT NULL, `ordering` smallint(6) NOT NULL, KEY `ID` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; ALTER TABLE `pmd_machinery` ADD CONSTRAINT `Reference2` FOREIGN KEY (`domain_ID`) REFERENCES `pmd_domains` (`domain_ID`) ON DELETE NO ACTION ON UPDATE NO ACTION; I use Mysql 5.1.33 and i receive a error : ERROR 1005 <HY000> at line 1245342: 'Can't create the table mamaison_db1.#sql-a18_3f' Errcode: 150 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/196375-i-need-help-with-a-script-that-use-foreign-keys-and-innodb/ Share on other sites More sharing options...
Mchl Posted March 24, 2010 Share Posted March 24, 2010 #sql-a18_3f is not a correct table name. Why your script try to create a table called like that, is up to you to find out. Quote Link to comment https://forums.phpfreaks.com/topic/196375-i-need-help-with-a-script-that-use-foreign-keys-and-innodb/#findComment-1031161 Share on other sites More sharing options...
JustLikeIcarus Posted March 25, 2010 Share Posted March 25, 2010 The References section of your add constraint statement has an error specifically REFERENCES `pmd_domains` (`domain_ID`) should be REFERENCES `pmd_domains` (`id`) as pmd_domains.domain_id isnt the name of the column. Quote Link to comment https://forums.phpfreaks.com/topic/196375-i-need-help-with-a-script-that-use-foreign-keys-and-innodb/#findComment-1031398 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.