PostgreSQL存储过程简单示例。删除3个月以前的数据,由定时调度任务定时调度。
CREATE OR REPLACE FUNCTION delete_ebd_compute_log_three_month_ago_data() RETURNS void AS $BODY$ begin delete from ebd_compute_log where create_time < CURRENT_TIMESTAMP(0) :: TIMESTAMP WITHOUT TIME ZONE - interval '3 months'; END; $BODY$ LANGUAGE plpgsql VOLATILE; GRANT EXECUTE ON FUNCTION delete_ebd_compute_log_three_month_ago_data() TO public;