我有两个MySQL数据库:master
和slave
。 master
db包含memberid
字段。如何在memberid
db中引用slave
?这是我尝试使用slave
db但没有成功的原因:
DROP TABLE IF EXISTS `attend_date_temp`;
CREATE TABLE `attend_date_temp` (
`clientid` int(10) unsigned NOT NULL,
`groupid` int(10) unsigned NOT NULL,
`memberid` int(10) unsigned NOT NULL,
KEY `clientid` (`clientid`),
KEY `memberid` (`memberid`),
CONSTRAINT `attend_date_temp_ibfk_1` FOREIGN KEY (`clientid`) REFERENCES `clients` (`clientid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `attend_date_temp_ibfk_2` FOREIGN KEY (`memberid`) REFERENCES `master.members` (`memberid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8
当我在该表中查看memberid
外键时,收到此消息:
Table 'slave.master.members' doesn't exist.
有人可以告诉我我做错了什么吗? This is the reference I used. 感谢。
答案 0 :(得分:1)
T a[n]
应该是:
REFERENCES `master.members`
否则,它会尝试在REFERENCES `master`.`members`
数据库中找到一个名为master.members
的表。