更新时间:2024-06-29 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)

相关文档