创建或替换触发器postgres [英] Create or replace trigger postgres
问题描述
我想创建或替换 postgres表的触发器。但是,没有这样的sql表达式。
I want to "create or replace" a trigger for a postgres table. However, there is not such sql expression.
我看到我可以执行 如果存在则触发触发器
首先( http://www.postgresql.org/docs/9.5/static /sql-droptrigger.html )。
I see that I can do a "DROP TRIGGER IF EXISTS
" first (http://www.postgresql.org/docs/9.5/static/sql-droptrigger.html).
我的问题是:
- 是否有比(
DROP
+CREATE
触发器) $ b $更推荐/更好的选择b - 有没有没有这样的创建或替换触发器的原因(这可能意味着我不希望这样做)
- Is there a recommended/better option than (
DROP
+CREATE
trigger) - Is there a reason why there is not such "create or replace trigger" (which might imply that I should not be wanting to do it)
请注意,oracle中有一个 创建或替换触发器
( https://docs.oracle.com/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm )。然后,
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,
- 是否已经为Postgres计划了这样的命令?
推荐答案
Postgresql具有事务DDL,因此 BEGIN> >创建>提交
等效于创建或替换
Postgresql has transaction DDL so BEGIN > DROP > CREATE > COMMIT
is the equivalent of CREATE OR REPLACE
这很好地描述了postgre的事务性DDL与其他系统(例如oracle)的比较方式
This is a nice write-up of how postgre's transactional DDL compares to other systems (such as oracle)
有关触发的当前postgres计划功能不包括添加 REPLACE
语法。
Current postgres planned features regarding triggers do not include adding the REPLACE
syntax.
这篇关于创建或替换触发器postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!