stored procedures 存储过程介绍
来源:互联网 发布:组卷 源码 编辑:程序博客网 时间:2024/06/16 11:36
什么是存储过程呢?
The stored procedures is a set of sqls which have been compiled and stored in the web server. If you want to execute some sqls you can transmit the stored procedure to the server, and it can be executed on the server. So it can also prevent the SQL injection attack.
Other advantages: High execute speed, modular programming, reduce the sql network flow.
定义:
将常用的或很复杂的工作,预先用SQL语句写好并用一个指定的名称存储起来, 那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。
存储过程的优点:
1.存储过程只在创造时进行编译,以后每次执行存储过程都不需再重新编译,而一般SQL语句每执行一次就编译一次,所以使用存储过程可提高数据库执行速度。
2.当对数据库进行复杂操作时(如对多个表进行Update,Insert,Query,Delete时),可将此复杂操作用存储过程封装起来与数据库提供的事务处理结合一起使用。
3.存储过程可以重复使用,可减少数据库开发人员的工作量
4.安全性高,可设定只有某此用户才具有对指定存储过程的使用权
总结起来就是:
1.执行速度更快 – 在数据库中保存的存储过程语句都是编译过的
2.允许模块化程序设计 – 类似方法的复用
3.提高系统安全性 – 防止SQL注入
4.减少网络流通量 – 只要传输存储过程的名称
存储过程的种类:
1.系统存储过程:以sp_开头,用来进行系统的各项设定.取得信息.相关管理工作,
如 sp_help就是取得指定对象的相关信息
2.扩展存储过程 以XP_开头,用来调用操作系统提供的功能
exec master..xp_cmdshell 'ping 10.8.16.1'
3.用户自定义的存储过程,这是我们所指的存储过程
常用格式
Create procedure procedue_name
[@parameter data_type][output]
[with]{recompile|encryption}
as
sql_statement
解释:
output:表示此参数是可传回的
with {recompile|encryption}
recompile:表示每次执行此存储过程时都重新编译一次
encryption:所创建的存储过程的内容会被加密
存储过程的3种传回值:
1.以Return传回整数
2.以output格式传回参数
3.Recordset
传回值的区别:
output和return都可在批次程式中用变量接收,而recordset则传回到执行批次的客户端中
关于SQL SERVER 2005与SQL SERVER 2000的存储过程创建的位置,
- stored procedures 存储过程介绍
- ASP与存储过程(Stored Procedures)
- ASP与存储过程(Stored Procedures)
- STORED PROCEDURES: GOOD OR BAD(存储过程:好还是坏)
- Lesson 07: Using Stored Procedures(使用存储过程)
- SQL Server 2000 未公开的存储过程 (Undocumented Stored Procedures)
- 一些在SQL帮助中找不到的系统存储过程 - System stored procedures
- 在Oracle中使用Java存储过程JSP(Java Stored Procedures)一些技术要点
- Stored Procedures
- 存储过程 stored procedure
- 存储过程(Stored Procedure)
- Stored Procedure/存储过程
- 存储过程 Stored Procedure
- 存储过程(Stored Procedure)
- Stored Procedures and Functions
- MySQL Stored Procedures
- Undocumented System Stored Procedures
- Stored Procedures: Returning Data
- IOS Info.plist
- ctex2.9.2输出中文
- Android HttpClient基本使用方法
- 替换switch case方法的方式2--反射
- ACM_todo
- stored procedures 存储过程介绍
- 用GDB调试程序(一)
- 给定一个存放整数的数组,重新排列数组使得数组左边为奇数,右边为偶数
- 字符串处理工具类
- android httpclient 上传文件
- 内核驱动的Makefile
- Unit1 名词,冠词
- 打开一个有delegation的文件(权限冲突)
- Android NDK纯C++开发(1)