SQL 2008中游标的用途是什么?谁能用简单的话解释一下? [英] What is the use of cursor in SQL 2008? Can anyone explain in simple words?

查看:66
本文介绍了SQL 2008中游标的用途是什么?谁能用简单的话解释一下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在sql中使用Cursor进行更新,删除,求和(金额),更改。但我们也可以使用普通查询来做到这一点。那么为什么我们使用Cursor虽然返回输出的速度很慢?



我尝试了什么:



尝试了Google的一些光标示例。

We can do update, delete, sum(amount),alter using Cursor in sql. But we can do this using normal queries also. Then why does we use Cursor though it is very slow to return output?

What I have tried:

Tried some Cursor examples from Google.

推荐答案

阅读文档:

DECLARE CURSOR(Transact-SQL)| Microsoft Docs [ ^ ]

SQL Server游标教程 [ ^ ]

第1部分:游标如何工作 [ ^ ]
Read the documentation :
DECLARE CURSOR (Transact-SQL) | Microsoft Docs[^]
SQL Server cursor tutorial[^]
Part 1: How cursors work[^]


它是很可能你根本不需要光标。 SQL是基于集合的。



我写了一篇文章来解释为什么处理SQL Server中的循环 [ ^ ]
It's quite probable that you do not need a cursor at all. SQL is set-based.

I wrote an article to explain why Processing Loops in SQL Server[^]


这篇关于SQL 2008中游标的用途是什么?谁能用简单的话解释一下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆