我需要我的表,另外一个是在不同的数据库(比如表链接logs
的device
数据库和表accounts
在user
分贝,无论是同一台服务器上)。因此,使用外部数据包装器我创建了一个外部表(我通过select * from accounts;
在device
成功运行的db 中运行来检查它)。
但是我仍然无法从device
db创建到外表的外键
CREATE TABLE public.logs
(
id bigint NOT NULL DEFAULT nextval('logs'::regclass),
...
account_id bigint,
...
CONSTRAINT logs_account_id_fkey FOREIGN KEY (account_id)
REFERENCES public.accounts (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
Run Code Online (Sandbox Code Playgroud)
错误信息是
ERROR: referenced relation "accounts" is not a table
********** Error **********
ERROR: referenced relation "accounts" is not a table
SQL state: 42809
Run Code Online (Sandbox Code Playgroud)