最近有朋友問起SP的解釋,我說這個是SQL的基礎概念之一,定義應該很清楚,網上隨即可查。他說他們公司一搞技術的領導說12年後SP的實現方法有變化,原來的定義解釋太單一。數據庫
好吧,我在網上也沒查到具體什麼變化,但想一想數據庫實現,幾個主流的大公司在底層都有不一樣的實現方式,MS SQL Server/ MySQL/ Oracle, 可能這些數據庫對SP的實現方法不同,可是從概念定義上應該沒變化。express
搜了搜wikipedia上的定義,再來看看SP的解釋:app
A stored procedure is a subroutine available to applications that access a relational database system. A stored procedure (sometimes called a proc, sproc,StoPro, StoredProc, StoreProc, sp or SP) is actually stored in the database data dictionary.ui
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.spa
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翻譯
我的翻譯:orm
存儲過程(SP)是可供應用調用來訪問關係數據庫的子程序。SP通常存儲在數據庫的數據字典裏。
ip典型應用包括數據校驗(集成在數據庫中)或數據控制。更進一步的,SP能夠鞏固和集中最初在應用程序中實現的邏輯。須要執行多條SQL語句的多操做或複雜操做被移動到SP中,全部的應用程序均可以調用這個procedure。get
說到數據庫變化,近幾年新起非關係型(NoSQL)數據庫,查了一下NoSQL也有本身的存儲過程。其實SP說白了就是一段放在數據庫端的「小」程序,經過此數據庫的語法語言就能調用,實現必定的功能。若是說定義有變化的話,能夠把這段加上。it