CREATE RULE(7) SQL Commands CREATE RULE(7) NAME CREATE RULE - SYNOPSIS CREATE [ OR REPLACE ] RULE name AS ON event TO table [ WHERE condition ] DO [ INSTEAD ] { NOTHING | command | ( command ; command ... ) } DESCRIPTION CREATE RULE CREATE OR REPLACE RULE PostgreSQL ``The Rule System'' ON SELECT INSTEAD SELECT ON SELECT SELECT CREATE VIEW ON SELECT ON INSERTON UPDATE ON DELETE INSTEAD INSTEAD DO INSTEAD NOTHING INSTEAD INSTEAD NOTHING PARAMETERS name event SELECT UPDATEDELETE INSERT table condition SQL boolean NEW OLD command SELECTINSERT UPDATEDELETE NOTIFY condition command NEW OLD new ON INSERT ON UPDATE OLD ON UPDATE ON DELETE NOTES RULE PostgreSQL SELECT PostgreSQL CREATE RULE "_RETURN" AS ON SELECT TO t1 DO INSTEAD SELECT * FROM t2; CREATE RULE "_RETURN" AS ON SELECT TO t2 DO INSTEAD SELECT * FROM t1; SELECT * FROM t1; NOTIFY NOTIFY --- NOTIFY CREATE RULE notify_me AS ON UPDATE TO mytable DO NOTIFY mytable; UPDATE mytable SET name = 'foo' WHERE id = 42; NOTIFY UPDATE id = 42 COMPATIBILITY CREATE RULE PostgreSQL Postgresql man man https://github.com/man-pages-zh/manpages- zh SQL - Language Statements 2003-11-02 CREATE RULE(7)