what is cursor in sql and types of cursor
what is cursor
Cursor is a Temporary Memory or Temporary Work Station. It is Allocated by Database Server at the Time of Performing DML(Data Manipulation Language) operations on the Table by the User. Cursors are used to store Database Tables. There are 2 types of Cursors: Implicit Cursors, and Explicit Cursors
Types of cursor in sql
SQL cursors can be categorized into two types based on how they are initiated, and four types based on their behavior:
a. Initiation: Implicit and explicit
b. Behavior: Static, dynamic, forward-only, and scrollable
Here are some of the types of SQL cursors:
c. Static cursor:
Captures a snapshot of the data when the cursor is opened, and does not reflect changes made to the data after that. This type of cursor is used when working with a stable result set.
d. Dynamic cursor:
Reflects all changes made to the data while the cursor is open. This type of cursor is used when viewing and processing real-time changes to the database.
e . Keyset-driven cursor:
A combination of static and dynamic cursors. The membership and order of rows in the result set is fixed when the cursor is opened, but changes to nonkey columns are visible. This type of cursor updates the keyset when data changes after opening the cursor.
No comments:
Post a Comment