TaB
TaB

Reputation: 129

postgres> Create a trigger in another schema

I am using postgres 9.5 and I loin to a database xyz as postgres user. Now I need to create a trigger in schema abc. The trigger will be a before delete or update on table Tab1 which is in schema def.

psql -d xyz

xyz=#create trigger abc.trg_name before delete or update on col1 ON DEF.Tab1
FOR EACH ROW EXECUTE PROCEDURE abc.proc1();

However, I am unable to do so. I get syntax error near "."

when I try using doublequotes, the TRIGGER gets created but not in abc schema - in DEF schema ( the schema of the underlying table):

create trigger "abc.trg_name" before delete or update on col1 ON DEF.Tab1
FOR EACH ROW EXECUTE PROCEDURE abc.proc1();

Is there a way in Postgres to create trigger in a schema different from its underlying referenced table?

I tried setting the SEARCH_PATH to abc, but it still creates it under DEF schema. Thanks for reply in advance!

Upvotes: 6

Views: 7951

Answers (1)

JGH
JGH

Reputation: 17836

No.

The doc says

The name cannot be schema-qualified — the trigger inherits the schema of its table.

Upvotes: 16

Related Questions