Lesson 21. Using Cursors

In this lesson, you'll learn what cursors are and how to use them.

Understanding Cursors

SQL retrieval operations work with sets of rows known as result sets. The rows returned are all the rows that match a SQL statement—zero or more of them. Using simple SELECT statements, there is no way to get the first row, the next row, or the previous 10 rows. This is an integral part of how a relational DBMS works.


Result Set The results retrieved by a SQL query.

Sometimes there is a need to step through rows forward or backward and one or more at a time. This is what cursors are used for. A cursor is a database query stored ...

Get Sams Teach Yourself SQL™ in 10 Minutes, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.