更新时间:2024-03-06 GMT+08:00

触发器函数

  • pg_get_triggerdef(oid)

    描述:获取触发器的定义信息。

    参数:待查触发器的OID。

    返回值类型:text

    示例:

    1
    2
    3
    4
    5
    select pg_get_triggerdef(oid) from pg_trigger;
                                                      pg_get_triggerdef
    ----------------------------------------------------------------------------------------------------------------------
     CREATE TRIGGER insert_trigger BEFORE INSERT ON test_trigger_src_tbl FOR EACH ROW EXECUTE PROCEDURE tri_insert_func()
    (1 row)
    
  • pg_get_triggerdef(oid, boolean)

    描述:获取触发器的定义信息。

    参数:待查触发器的OID及是否以pretty方式展示。

    返回值类型:text

    仅在创建trigger时指定WHEN条件的情况下,布尔类型参数才生效。

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    select pg_get_triggerdef(oid,true)from pg_trigger;
                                                      pg_get_triggerdef
    ----------------------------------------------------------------------------------------------------------------------
     CREATE TRIGGER insert_trigger BEFORE INSERT ON test_trigger_src_tbl FOR EACH ROW EXECUTE PROCEDURE tri_insert_func()
    (1 row)
    
    select pg_get_triggerdef(oid,false)from pg_trigger;
                                                      pg_get_triggerdef
    ----------------------------------------------------------------------------------------------------------------------
     CREATE TRIGGER insert_trigger BEFORE INSERT ON test_trigger_src_tbl FOR EACH ROW EXECUTE PROCEDURE tri_insert_func()
    (1 row)