SHOW TRIGGERS

功能描述

显示有关存储函数的信息。

注意事项

N/A

语法格式

SHOW TRIGGERS {FROM | IN} db_name [LIKE 'pattern' | WHERE expr]

参数说明

  • db_name

    库名(或schema)。

  • WHERE expr

    筛选表达式。

  • LIKE 'pattern'

    pattern正则表达式匹配触发器名字。

返回结果集

字段名类型说明
Trigger触发器名称
Event触发器事件(Insert、delete、update、truncate)
Table触发器定义的表
Statement触发器内容
Timing触发器时机(触发器之前或之后)
Created触发器创建时间此处为空
sql_mode触发器创建时的sql mode此处为空
Definer创建者
character_set_client创建时客户端的字符集此处为空
collation_connection创建时客户端的排序规则此处为空
Database Collation数据库的排序集

实例

opengauss=# -- 创建触发器表和触发器函数
opengauss=# CREATE TABLE test_trigger_src_tbl(id1 INT, id2 INT, id3 INT);
CREATE OR REPLACE FUNCTION tri_insert_func() RETURNS TRIGGER AS $$ DECLARE BEGIN INSERT INTO test_trigger_des_tbl VALUES(NEW.id1, NEW.id2, NEW.id3); RETURN NEW; END $$ LANGUAGE PLPGSQL;
-- 创建触发器
CREATE TRIGGER insert_trigger BEFORE INSERT ON test_trigger_src_tbl FOR EACH ROW EXECUTE PROCEDURE tri_insert_func();
-- 查看信息
show triggers;
CREATE TABLE
opengauss=# CREATE TABLE test_trigger_des_tbl(id1 INT, id2 INT, id3 INT);
CREATE TABLE
opengauss=# CREATE OR REPLACE FUNCTION tri_insert_func() RETURNS TRIGGER AS $$ DECLARE BEGIN INSERT INTO test_trigger_des_tbl VALUES(NEW.id1, NEW.id2, NEW.id3); RETURN NEW; END $$ LANGUAGE PLPGSQL;
CREATE FUNCTION
opengauss=# -- 创建触发器
opengauss=# CREATE TRIGGER insert_trigger BEFORE INSERT ON test_trigger_src_tbl FOR EACH ROW EXECUTE PROCEDURE tri_insert_func();
CREATE TRIGGER
opengauss=# -- 查看信息
opengauss=# show triggers;
    Trigger     | Event  |        Table         |              Statement              | Timing | Created | sql_mode | Definer | character_set_client | collation_connection | Database Collation
----------------+--------+----------------------+-------------------------------------+--------+---------+----------+---------+----------------------+----------------------+--------------------
 insert_trigger | INSERT | test_trigger_src_tbl | EXECUTE PROCEDURE tri_insert_func() | BEFORE |         |          | wyc     |                      |                      | en_US.UTF-8
(1 row)
意见反馈
编组 3备份
    openGauss 2024-07-15 01:00:27
    取消