I want to "create or replace" a trigger for a postgres table. However, there is not such sql expression.
I see that I can do a "DROP TRIGGER IF EXISTS
" first (http://www.postgresql.org/docs/9.5/static/sql-droptrigger.html).
My question are:
DROP
+ CREATE
trigger)Note that there is a "Create or Replace Trigger
" in oracle (https://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm). Then,
For older versions of PostgreSQL, using the transaction DDL BEGIN > DROP > CREATE > COMMIT
is the equivalent of CREATE OR REPLACE
This is a nice write-up of how postgre's transactional DDL compares to other systems (such as oracle)
However, as of PostgreSQL 14 introduces CREATE OR REPLACE TRIGGER