I have a rather simple question. I need to create the delete trigger.
I have three table, Main and T1 and T2. The T1 and T2 are connecting to Main with the same ID field so I already开发者_如何学JAVA have insert trigger that works great but I need delete trigger which will delete record in T1 and T2 when deleted from the Main table.
Any help?
A delete trigger would fire after the DELETE runs. However, the DELETE will fail because of foreign key errors (you have FKs, right?).
Options:
- Stored procedure to delete T2, T1 then Main in a transaction
- Set the FKs to have cascading delete
- Instead of trigger (which fires before the delete) which is effectively like a stored procedure
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论