Provided by: manpages-zh_1.5.2-1_all bug

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  <laser@pgsqldb.org>