什么时候数据库触发器不好?

When are database triggers bad?(什么时候数据库触发器不好?)
本文介绍了什么时候数据库触发器不好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
数据库触发器是邪恶的吗?

有很多关于数据库触发器的负面信息,只是想了解社区对什么时候好还是坏的看法.

There is lot of negative information on database triggers, just want to get the community's take on when is it good vs bad.

推荐答案

我认为当它们用于填充单独的、一次性的表集以用于日志记录、聚合等以确保安全性或创建例如元数据.

I think they're OK when they are used to populate a separate, one-off set of tables for things like logging, aggregation etc. for security or creating metadata for example.

当您开始更改实时"数据或返回"到您的商业信息表时,它们就会变得邪恶和笨拙.为此,它们也完全没有必要.没有什么是触发器做不到的,而存储过程是做不到的.

When you start altering your "live" data or "looping back" into your biz info tables, that's when they become evil and unwieldy. They are also utterly unnecessary for this. There is nothing that a trigger does that a stored proc cannot do.

我觉得它们是 SQL 的邪恶,相当于编程语言中的 GOTO.合法,但除非绝对必要,否则应避免使用,而且它们从来都不是绝对必要的.

I feel like they are SQL's evil equivalent to GOTOs in programming languages. Legal, but to be avoided unless absolutely necessary, and they are NEVER absolutely necessary.

这篇关于什么时候数据库触发器不好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)