數據庫觸發器是邪惡的嗎? [關閉] - Are database triggers evil? [closed]

問題:

As it currently stands, this question is not a good fit for our Q&A format. 就目前而言,這個問題不適合我們的問答形式。 We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. 我們希望答案得到事實、參考或專業知識的支持,但這個問題可能會引起辯論、爭論、投票或擴展討論。 If you feel that this question can be improved and possibly reopened, visit the help center for guidance. 如果您認爲此問題可以改進並可能重新打開,請訪問幫助中心以獲取指導。
Closed 9 years ago . 9年前關閉。

Are database triggers a bad idea?數據庫觸發器是一個壞主意嗎?

In my experience they are evil, because they can result in surprising side effects, and are difficult to debug (especially when one trigger fires another).根據我的經驗,它們是邪惡的,因爲它們會導致令人驚訝的副作用,並且難以調試(尤其是當一個觸發器觸發另一個時)。 Often developers do not even think of looking if there is a trigger.通常,開發人員甚至不會考慮查看是否有觸發器。

On the other hand, it seems like if you have logic that must occur evertime a new FOO is created in the database then the most foolproof place to put it is an insert trigger on the FOO table.另一方面,如果在數據庫中創建新的FOO必鬚髮生邏輯,那麼放置它的最簡單的地方是 FOO 表上的插入觸發器。

The only time we're using triggers is for really simple things like setting the ModifiedDate .我們使用觸發器的唯一時間是非常簡單的事情,比如設置ModifiedDate


解決方案:

參考一: https://en.stackoom.com/question/1vkS
參考二: https://stackoom.com/question/1vkS
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章