Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

postgres> Create a trigger in another schema

Tags:

postgresql

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!

like image 838
TaB Avatar asked Aug 28 '26 18:08

TaB


1 Answers

No.

The doc says

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

like image 178
JGH Avatar answered Aug 30 '26 11:08

JGH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!