测试1:创建触发器
Create table te1(id int);
Create table te2(id int);
--创建触发器函数
create FUNCTION INSERT_into_te2 ()
RETURNS TRIGGER AS $$
BEGIN
INSERT INTO te2 VALUES (NEW.id);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
--创建触发器
CREATE TRIGGER tri_inert_te2 BEFORE INSERT ON te1 FOR EACH ROW EXECUTE procedure insert_into_te2();
--触发器使用
insert into te1 values (1);
select * from te2;
测试2:删除触发器
drop trigger tri_inert_te2 on te1;
drop table te1;
drop table te2;
drop function insert_into_te2();