CREATE OR REPLACE FUNCTION products_insert_trigger_func() RETURNS TRIGGER AS $$
DECLARE
BEGIN
RAISE NOTICE 'the function products_insert_trigger_func has been invoked'; --抛出提示
RETURN null;
END
$$
LANGUAGE plpgsql; --创建触发器函数
CREATE FUNCTION
highgo=# CREATE TRIGGER tg1 AFTER INSERT ON products FOR EACH ROW EXECUTE PROCEDURE products_insert_trigger_func(); --创建触发器,定义在 INSERT 之后的行级触发器
CREATE TRIGGER
highgo=# INSERT INTO products VALUES(3,'c',3); --触发
注意: the function products_insert_trigger_func has been invoked
INSERT 0 1
CREATE TABLE public.products (
product_no int4,
"name" text,
price numeric
);