黑马程序员之存储过程学习笔记:存储过程的基本使用
来源:互联网 发布:网络诈骗投诉电话多少 编辑:程序博客网 时间:2024/09/21 09:02
--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!---------------------------------------------------------
存储过程的概念:
存储过程的概念:
存储过程是一种数据库对象,为了实现某个特定的任务,将一组预编译的SQL语句将以一个存储单元的形式存储在服务器上,供用户调用,存储过程在第一次执行时进行编译,然后将编译好的代码保存在高速缓存中,以便以后调用,这样可以提高代码的执行效率。
--创建一个简单的存储过程
create proc UserId @name varchar(30)
as
select LoginId from UserInfo where LoginPWD=@name
---执行存储过程
execute UserId
---查看存储过程的一般信息
exec sp_help UserId
---查看存储过程的定义信息
exec sp_helptext UserId
---查看存储过程的相关性
exec sp_depends UserId
---创建带有返回参数的存储过程
create proc score @name float output
as
select @name=AVG(StudentResult) from Result
----执行返回参数的操作
declare @pj float
exec score @pj output
print '所有学生的平均成绩是:'+STR(@pj)
---创建多个参数的存储过程
create proc score @studentno varchar(30) ,@grade float output
as
select @grade=StudentResult from Result where StudentNo=@studentno
declare @chengji float
exec score '001',@chengji output
print'此学生的成绩是:'+STR(@chengji)
存储过程的优点:
执行速度更快;允许模块化程序设计;提高系统安全性;减少网络流通量。
--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!---------------------------------------------------------
--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!---------------------------------------------------------
- 黑马程序员之存储过程学习笔记:存储过程的基本使用
- 黑马程序员--SQL学习笔记之存储过程
- 【黑马程序员】SQLserver笔记之存储过程
- 黑马程序员--存储过程
- 黑马程序员学习日记----通用存储过程
- 黑马程序员之C#学习笔记:后台C#调用存储过程
- 黑马程序员之ORACLE数据库学习笔记:oracle存储过程单步调试方法
- 存储过程的基本使用
- Oracle 笔记之 存储过程的使用
- 黑马程序员--分页存储过程
- 黑马程序员--创建存储过程
- 存储过程学习笔记
- 存储过程学习笔记
- 存储过程学习笔记
- MYSQL入门学习之十二:存储过程的基本操作
- MYSQL入门学习之十二:存储过程的基本操作
- 存储过程使用学习
- oracle之存储过程4-存储过程变量的使用
- 程序员每天该做的事
- java网络编程基础概念
- 闲说HeartBeat心跳包和TCP协议的KeepAlive机制
- linux shell--read命令详解
- Qt学习之路(46): 自定义model之二
- 黑马程序员之存储过程学习笔记:存储过程的基本使用
- ssh框架中插入数据到mysql出现乱码
- 宾馆管理系统
- 进程间通信 - 命名管道实现
- Qt学习之路(47): 自定义Model之三
- Pentadactyl/Vimperator:VIM化的Firefox
- JQUERY仿蘑菇街布局
- 关于Android下各个布局方式里面LayoutParams的用法
- Android Framework 框架(DecorView)