Opentopia Directory Encyclopedia Tools

Cursor (databases)

Encyclopedia : C : CU : CUR : Cursor (databases)


In database packages, the term cursor refers to a control structure for the successive (and potential processing) of records in a result set as returned by a query.

Cursors may be implemented on the client side or the server side of the database connection. A client-side cursor is necessary for processing individual rows returned from the database because many languages do not offer any other mechanism for manipulating individual rows in the result set. In this way, a cursor can be thought of as an iterator over the collection of rows in the result set.

Several database operations do not provide an opportunity for the use of cursors. The INSERT statement, for example, as well as most forms of the DELETE and UPDATE statements. Even a SELECT statement may not involve the use of a cursor if it returns no rows, or only one row.

On the server side, a cursor similarly allows an SQL statement's results to be used or examined one row at a time. Typically, server-side cursors are not necessary because most statements can be written using other SQL constructs that allow the database to carry out the intended operations more efficiently. They are rarely required.

Types of cursors: Static, Dynamic, Forward-only, Keyset-driven.

Disadvantages of cursors: Each time you fetch a row from the cursor, it results in a network round trip, where as a normal SELECT query makes only one round trip, however large the result set is. Cursors are also costly because they require more resources and temporary storage (results in more I/O operations). Further, there are restrictions on the SELECT statements that can be used with some types of cursors.

References

See also

External links

Topics in database management systems (DBMS)[ view][ talk][ edit] )
Concepts
Database | Database model | Relational database | Relational model | Relational algebra | Primary key - Foreign key - Surrogate key - Superkey
Database normalization | Referential integrity | Relational DBMS | Distributed DBMS | ACID

Objects
Trigger | View | Table | Cursor | Log | Transaction | Index | Stored procedure | Partition
Topics in SQL
Select | Insert | Update | Merge | Delete | Join | Union | Create | Drop
Comparison of syntax

Implementations of database management systems
Types of implementations
Flat file | Deductive | Dimensional | Hierarchical | Object oriented | Temporal

Products
dBASE | Oracle | Sybase | MySQL | Microsoft SQL Server | PostgreSQL | DB2 | Comparison - relational | Comparison - object-relational
Components
Query language | Query optimizer | Query plan | ODBC | JDBC
Lists
List of object-oriented database management systems
List of relational database management systems
List of truly relational database management systems

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: