什么是 SQL 游标以及如何将它们应用到简单的数据库表?
我试图了解游标是什么以及它们对我作为开发人员有什么用处。
请解释它们是什么以及它们使用带有 IQueryable
集合的实体框架带来的好处。
另外,假设我有一张名为 Person 的表。我如何将游标应用于该表?
create table Person
(
ID int primary key,
Name nvarchar,
LastName nvarchar
);
I'm trying to understand what cursors are and what use they are to me as a developer.
Please explain what they are and what benefit they bring over using say Entity Framework with an IQueryable<T>
collection.
Also, imagine I have a table called Person. How would I apply cursors to this table?
create table Person
(
ID int primary key,
Name nvarchar,
LastName nvarchar
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
游标允许逐行处理。最好避免使用游标,因为与基于集合的查询操作相比,它们通常非常慢。以下是一些有关游标的文档,可帮助您入门:DECLARE CURSOR (Transact-SQL)< /a>
Cursors allow to process rows one by one. It's better to avoid using cursors as they are usually very slow compared to set based query operations. Here is some documentation about cursors to get you started: DECLARE CURSOR (Transact-SQL)