I need to link my table with another one which is in different database(say table logs in device db and table accounts in user db, both on same server). So using Foreign Data Wrapper I create a foreign table(I check it with running select * from accounts; in device db which works successfully).
But I could not create a foreign key to foreign table from device db still
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
)
The error message is
ERROR: referenced relation "accounts" is not a table
********** Error **********
ERROR: referenced relation "accounts" is not a table
SQL state: 42809