这是SQL:
CREATE TABLESPACE fnord1 location '/tmp/fnord1';
CREATE TABLESPACE fnord2 location '/tmp/fnord2';
CREATE SCHEMA IF NOT EXISTS fnord;
DROP TABLE IF EXISTS fnord.shea;
DROP TABLE IF EXISTS fnord.wilson;
CREATE TABLE fnord.shea (
id text not null,
CONSTRAINT fnord_shea_id PRIMARY KEY (id) USING INDEX TABLESPACE fnord2
) TABLESPACE fnord1;
CREATE TABLE fnord.wilson (
thing text not null,
shea_id bigserial not null,
CONSTRAINT fnord_wilson_id PRIMARY KEY (thing, shea_id) USING INDEX TABLESPACE fnord2,
CONSTRAINT fnord_wilson_shea_fkey FOREIGN KEY (shea_id) REFERENCES fnord.shea.id
) TABLESPACE fnord1;
由于带有
的外键声明,因此失败错误:未实现跨数据库引用:“fnord.shea.id”
但是......这些都在同一个数据库中,不是吗?如果没有,将它们放在同一个数据库中的正确方法是什么?
答案 0 :(得分:0)
使用schema.table_name(column_name)
:
CONSTRAINT fnord_wilson_shea_fkey FOREIGN KEY (shea_id) REFERENCES fnord.shea.id
到
CONSTRAINT fnord_wilson_shea_fkey FOREIGN KEY (shea_id) REFERENCES fnord.shea(id)