数据库表之间的相互影响如何实现?

来源:百度知道 编辑:UC知道 时间:2024/06/16 17:56:12
比如现在有3张表
表1,表2,表3
现在在表1插入一行数据
如何实现自动根据插入的这一行的某个列值把数据分类到表2或表3

除了用触发器实现,还有没有别的实现方法
例如在设计表的时候建立什么联系的来实现?

Trigger is a better way to realize you requirement.

besides, u can write the loggic in SQL that when insertting to table1,insert the same value to table2 or table3 according to the value. (which DB do you use? does it support "IF" sentence?)

or by DB2 PROCEDURE, It's the same more or less

如果不用触发器就用sql的事务来完成。完全代码控制。

通过外码主键的设置就可以了吧!

其实通过触发器来实现这个功能已经很好了!!!