标签:
1、触发器
有更新操作时记录一条日志
DROP FUNCTION IF EXIST log_test(); CREATE OR REPLACE FUNCTION log_test() RETURNS trigger AS $$ DECLARE BEGIN RAISE NOTICE ‘TRIGGER LOG TEST‘; RETURN NULL; END; $$ LANGUAGE plpgsql; CREATE TRIGGER log_trigger AFTER UPDATE on emps FOR EACH ROW EXECUTE Procedure log_test(); UPDATE emps SET salary = 8000.0 WHERE userid = 10;
2、视图
2.1、视图是预先定义的SQL查询,因此表中数据变化,视图也会变化;
2.2、它暴露有限的数据对客户,有利于权限控制;
2.3、视图中没有实际的物理数据,是一个逻辑的概念;
CREATE VIEW salarys AS SELECT userid AS id, salary AS money FROM emps WHERE salary > 1000; SELECT * FROM VIEW;
标签:
原文地址:http://www.cnblogs.com/Fredric-2013/p/4653762.html