什么时候应该使用存储过程?

什么时候应该使用存储过程?

问题描述:

我应该何时使用存储过程,而不是直接在我的应用程序中写入逻辑?我想获得存储过程的好处,但我也不希望我的应用程序逻辑分散在数据库和应用程序。

When should I be using stored procedures instead of just writing the logic directly in my application? I'd like to reap the benefits of stored procedures, but I'd also like to not have my application logic spread out over the database and the application.

有什么经验可以参考吗?

Are there any rules of thumb that you can think of in reference to this?

哇...我要直接对着这里的游泳,说,几乎总是。有一个洗衣名单的原因 - 一些/许多,我相信其他人会争辩。但是我开发了应用程序,无论是否使用存储过程作为数据访问层,并且我的经验是,良好的编写存储过程使编写应用程序变得更容易。然后有良好的记录的性能和安全优势。

Wow... I'm going to swim directly against the current here and say, "almost always". There are a laundry list of reasons - some/many of which I'm sure others would argue. But I've developed apps both with and without the use of stored procs as a data access layer, and it has been my experience that well written stored procedures make it so much easier to write your application. Then there's the well-documented performance and security benefits.