what is cursor in dbms

what is cursor in dbms

1 year ago 40
Nature

In DBMS, a cursor is a temporary work area that is created in the system memory when DML (Data Manipulation Language) statements like INSERT, UPDATE, and DELETE are executed. A cursor can have more than one row, but processing-wise, only one row is taken into account. Cursors are used to store database tables and are helpful in all kinds of databases like Oracle, SQL Server, MySQL, etc. . Cursors are of two types: Implicit Cursors and Explicit Cursors.

  • Implicit Cursors: These cursors are also known as default cursors of SQL SERVER. They are allocated by the database server when the user performs DML operations like INSERT, UPDATE, and DELETE. Implicit cursors are very easy to use and require less coding.

  • Explicit Cursors: These cursors are created by the user using the SELECT query. An explicit cursor holds multiple records but processes a single row at a time. It uses the pointer, which moves to another row after reading one row. It is basically used for gaining extra control over the temporary workstation. Explicit cursors provide more flexibility and control.

Cursors are particularly useful when dealing with large result sets, as they allow the programmer to access data in a more efficient manner without having to retrieve the entire data set at once. Cursors are used by database programmers to process individual rows returned by database system queries. Cursors enable manipulation of whole result sets at once).

Read Entire Article