工作中遇到一个表需要另一个表的数据,而做视图的话会影响一堆程序..于是加了个字段再写了个触发器.这是第一次写触发器.感觉挺不错.这东西很方便,以下是实例:
create or replace trigger T_YJZT
after update on bz_txb
declare
-- local variables here
begin
update bz_gzdg set yjzt=(select yjzt from bz_txb where bz_txb.xh=bz_gzdg.xmbh);
update bz_jysxx set yjzt=(select yjzt from bz_txb where bz_txb.xh=bz_jysxx.xmbh);
update bz_ssgxx set yjzt=(select yjzt from bz_txb where bz_txb.xh=bz_ssgxx.xmbh);
update bz_bpgxx set yjzt=(select yjzt from bz_txb where bz_txb.xh=bz_bpgxx.xmbh);
update bz_ZQYJ set yjzt=(select yjzt from bz_txb where bz_txb.xh=bz_ZQYJ.xmbh);
end T_YJZT;
创建触发器和删除触发器和创建表删除表看来差不多..
Oracle的确是很优秀的数据库..呵呵