数据库笔记 6
来源:互联网 发布:mac firefly安装 编辑:程序博客网 时间:2024/06/07 11:04
7.2
/*创建游标testCursorA,把testCursorA看成存放游标的容器,查询网站职员表的游标记录放入testCursorA,约束为制度游标*/
declare testCursorA cursor for
select *from AddressInfos
for read only/*当前为只读游标;去掉for read only,是标准游标;for update,是更新游标*/
/*打开游标*/
open testCursorA
/*使用游标,从testCursorA依次拿出放在testCursorA里面的游标*/
fetch nextfrom testCursorA
7.3游标定义格式
declare 游标名称cursor
[Local|Global]//游标的作用范围:局部|全局
[Forward_only|Scroll]//只进游标(从前往后走)|任意滚动
[Stattic|Keyset|Dynamic|Fast_froward]
[Reae Only|Scroll_Locks|Optimistic]
[Type_warning]
for
...Sql语句...
for [read only|update]
7.4
/*创建任意滚动游标*/
declare testCursorA cursor scroll for
select *from 网站职员表
/*调用查询下一个游标*/
fetch nextfrom testCursorA
/*调用查询第一个游标*/
fetch firstfrom testCursorA
/*调用查询最后一个游标*/
fetch lastfrom testCursorA
7.5
/*创建可滚动游标*/
declare testCursorB cursorscrollfor
select *from AddressInfos
/*调用游标,从前往后获取游标记录*/
fetch priorfrom testCursorB
7.07
/*创建游标*/
declaretestCursorA cursor scrollfor
select *from dbo.第二网站职员表
/*打开游标*/
opentestCursorA
/*执行*/
fetch absolutefromtestCursorA
/*relative把游标向前或者向后移动一个位置;relative -1把游标向前移动一个位置;relative 1把游标向后移动一个位置*/
fetch relative-1from testCursorA
7.08
declare@testvar1 int,@testVar2varchar(100),@testVar3int,@testVar4varchar(100),@testVar5money
fetch relative-2from testCursorAinto@testVar1,@testVar2,@testVar3,@testVar4,@testVar5
7.09
/*关闭游标*/
closetestCursorA
/*释放游标*/
deallocatetestCursorA
- 数据库笔记 6
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- 数据库笔记
- springboot系列文章(一)-初识springboot
- 65-高级 I/O 函数与技术
- UNIX文件目录管理基本命令之移动光标屏幕翻滚插入文本
- The Debut Album (dp + 滚动数组)
- 深度学习在图像超分辨率重建中的应用
- 数据库笔记 6
- 门面模式(Facade 外观模式,对象结构型模式)
- iptables语法
- Matlab批量实现图片文件格式转换
- 安卓GridView不均分解决过程
- acm杭电acm5974 A Simple Math Problem 数论(最大公约数最小公约数,解方程x )
- Android开源库V
- 多线程系列提高(7)--同步工具类
- MySQL之聚合与排序