如何引用wp_users表

时间:2018-04-08 20:29:27

标签: mysql wordpress

我想在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)
)'.
------------

0 个答案:

没有答案