存储过程(Stored Procedure) 是什麽

最近有朋友问起SP的解释,我说这个是SQL的基础概念之一,定义应该很清楚,网上随便可查。他说他们公司一搞技术的领导说12年后SP的实现方法有变化,原来的定义解释太单一。

好吧,我在网上也没查到具体什么变化,但想想数据库实现,几个主流的大公司在底层都有不同的实现方式,MS SQL Server/ MySQL/ Oracle, 可能这些数据库对SP的实现方法不一样,但是从概念定义上应该没变化。

搜了搜wikipedia上的定义,再来看看SP的解释:

stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a procsproc,StoProStoredProcStoreProcsp or SP) is actually stored in the database data dictionary.

Typical use for stored procedures include data validation (integrated into the database) or access control mechanisms. Furthermore, stored procedures can consolidate and centralize logic that was originally implemented in applications. Extensive or complex processing that requires execution of several SQLstatements is moved into stored procedures, and all applications call the procedures. One can use nested stored procedures by executing one stored procedure from within another.

Stored procedures are similar to user-defined functions (UDFs). The major difference is that UDFs can be used like any other expression within SQL statements, whereas stored procedures must be invoked using the Call statement

个人翻译:

存储过程(SP)是可供应用调用来访问关系数据库的子程序。SP一般存储在数据库的数据字典里。

典型应用包括数据校验(集成在数据库中)或数据控制。更进一步的,SP可以巩固和集中最初在应用程序中实现的逻辑。需要执行多条SQL语句的多操作或复杂操作被移动到SP中,所有的应用程序都可以调用这个procedure。

说到数据库变化,近几年新起非关系型(NoSQL)数据库,查了一下NoSQL也有自己的存储过程。其实SP说白了就是一段放在数据库端的“小”程序,通过此数据库的语法语言就能调用,实现一定的功能。如果说定义有变化的话,可以把这段加上。


转载于:https://my.oschina.net/u/2274721/blog/349500

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值