如何使用phpMyAdmin添加指向同一个表的外键? [英] how do I add a foreign key pointing to the same table using phpMyAdmin?
问题描述
我有一个现有的InnoDB表,已经有外键指向不同的表。
但是当我尝试创建一个指向主索引的外键时,得到一个错误(检查数据类型)。
这个表是以User_Id为主的User。
I想要一个外键Manager_ID这是一个FK到User_Id。
两个
两个长度10
无符号...
但是我仍然得到一个数据检查错误...?
Manager_ID不是 设置为 NOT NULL
。
您必须允许nulls那个领域,作为公司最顶层的人将没有经理。
我找到了 a post over the MySQL boards that may help help。
I have an existing InnoDB table which already has foreign keys pointing to different tables.
But when I try to create a foreign key pointing to the Primary index, I get an error (check data type).
The table is User with User_Id as the Primary.
I want a foreign key Manager_ID which is a FK to User_Id.
Both of INT Both of Length 10 Unsigned...
But I still get a data check error...?
Make sure that Manager_ID is not set to NOT NULL
.
You have to allow nulls on that field, as the top-most person in the company will have no manager.
I found a post over on the MySQL boards that might help.
这篇关于如何使用phpMyAdmin添加指向同一个表的外键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!