I have two database say db1 and db2. And two tables user_auth_table in db1 and user_table in db2. Now I want to trigger a function which sync up few values in both tables for each new row or on each new insertion in user_auth_table.

I have tried to write on my own and creating trigger in db1. But the error says user_table doesn't exist. Which I know why I am getting this error. Any suggestion to target the tables outside the db ?

CREATE TRIGGER sync_user_table AFTER INSERT ON user_auth_table for each row execute procedure syncAndMaintainUsersTable()

create or replace function syncAndMaintainUsersTable()
returns trigger as
if NEW.user_uuid<>OLD.user_uuid then
    insert into user_table values (NEW.user_uuid, CURRENT_TIMESTAMP, NEW.provider);
end if;
return new;
language plpgsql;
  • Yes, it's the actual syntax Jun 15, 2020 at 13:31

1 Answer 1


Usually the full qualified name of a db table is:


If you want to insert some values into another table you should use this syntax:

insert into catalog.schema.table
values (..., ..., ...)
  • Thank you, this worked. Jun 20, 2020 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.