我想在wordpress数据库中添加一些表,并引用带有wp_users
约束的FOREIGN KEY
表。现在尝试了一下后,我继续得到以下输出:
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2018-04-08 22:27:20 31fc Error in foreign key constraint of table `wordpress`.`wp_foo`:
Create table `wordpress`.`wp_foo` with foreign key constraint failed. Referenced table `wordpress`.`wp_users` not found in the data dictionary near 'FOREIGN KEY (id) REFERENCES wp_users(id),
PRIMARY KEY (id)
)'.
------------
我执行的陈述:
CREATE TABLE wp_foo (
user_id bigint(20) unsigned,
FOREIGN KEY (user_id) REFERENCES wp_users(id),
PRIMARY KEY (user_id)
);
如何引用wp_users.ID
属性?
编辑:
更新声明后的输出(请参阅下面的评论):
------------------------
LATEST FOREIGN KEY ERROR
------------------------
2018-04-08 23:16:21 3470 Error in foreign key constraint of table `wordpress`.`wp_foo`:
Create table `wordpress`.`wp_foo` with foreign key constraint failed. Referenced table `wordpress`.`wp_users` not found in the data dictionary near 'FOREIGN KEY (user_id) REFERENCES wp_users(id),
PRIMARY KEY (user_id)
)'.
------------