This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 请教一个关于数据库表的问题:如果有两个表,表二的某列是表一中某列求和的结果,当表一中该列有了变化(插入,更新,删除),如何使得表二的这列自动重新计算并更新?是应该用trigger还是需要定义特殊的表类型?
-loveflute(花生米米);
2009-11-9
(#5668821@0)
-
把第二个表改成view?
-oasis(oasis);
2009-11-10
(#5668950@0)
-
What is the type of your 2nd 表? If it is view, you do not need to do anything. If that is a procedure used to generate 2nd 表, you do not need to do anything either. If that is a table, then just rerun the procedure which is used to generate the 2nd 表.
-registereduser(立牌坊);
2009-11-10
(#5669335@0)
-
用的是哪种数据库?最好不要用触发器。ORACLE有事务级自动刷新的聚合物化视图。但最好改为定时刷新否则影响并发性。
-newkid(newkid);
2009-11-10
(#5669581@0)
-
太谢谢楼上各位了,就是view,我几年前用过,现在怎么也想不起来了,另外再问一下,如果这个view中有一列是表一中某两项各自求和后相除的结果,在创建view时这个相除应该用什么operator?
-loveflute(花生米米);
2009-11-10
(#5669922@0)
-
oh I found it : truncate?
-loveflute(花生米米);
2009-11-10
(#5670167@0)
-
不会吧?除法在各种语言里都是一样的。SUM(F1)/SUM(F2) 你要的就是这个?
-newkid(newkid);
2009-11-10
(#5670240@0)
-
是啊是啊,我还以为得有个类似sum这样的operator,其实就是"\"而已,只不过用了truncate确定小数位。谢谢
-loveflute(花生米米);
2009-11-10
(#5670882@0)