jinyuttt

导航

postgresql数据库3种程序(rule,trigger ,FUNCTION )

1.

CREATE [ OR REPLACE ] RULE name AS ON event  

TO table_name [ WHERE condition ]  

 DO [ ALSO | INSTEAD ] { NOTHING | command | ( command ; command ... ) }  

 

2.

CREATE TRIGGER trigger_name [BEFORE|AFTER|INSTEAD OF] event_name ON table_name [ -- Trigger logic goes here.... ];

3.

 

CREATE [OR REPLACE] FUNCTION function_name (arguments) 
RETURNS return_datatype AS $variable_name$
  DECLARE
    declaration;
    [...]
  BEGIN
    < function_body >
    [...]
    RETURN { variable_name | value }
  END; LANGUAGE plpgsql; 

 

posted on 2017-03-02 20:50  代码苦行僧  阅读(1019)  评论(0编辑  收藏  举报