在phpmyadmin中添加FOREIGN KEY时出错?

时间:2012-11-13 08:12:54

标签: phpmyadmin foreign-keys

  

可能重复:
  Setting up foreign keys in phpMyAdmin?

ALTER table podcategory add FOREIGN KEY (category_id) 
           REFERENCES category(category_id)
ON UPDATE RESTRICT
ON DELETE CASCADE

当我在phpmyadmin发送脚本时,我收到错误

Can't create table './C292729_T25027/#sql-be0_30ed238.frm' (errno: 150)

如何添加此FOREIGN KEY?

1 个答案:

答案 0 :(得分:0)

尝试这种类型:

ALTER TABLE `aaaa` ADD CONSTRAINT fk_comp_id FOREIGN KEY ( `comp_id` ) REFERENCES `comps` ( `id` ); 

或者这个SO答案/问题可能会帮助您确定: Setting up foreign keys in phpMyAdmin?