In Computer science and technology, a database cursor is a control structure that enables traversal over the records in a database. Cursor in MySQL is almost the same as a cursor in other databases. MySQL cursor is a kind of loop facility given to traverse in the result of SQL one by one. We can operate on every result by using the cursor in MySQL. Cursors are supported in stored procedures, functions, and triggers only. MySQL cursor is available from version 5 or greater. Followings are the three main properties of MySQL cursor −
By using MySQL cursor, we cannot update any table.
MySQL cursors always fetch the rows in one direction i.e. from top to bottom. In other words, we can say that we cannot fetch rows in reverse order and we cannot skip rows or jump to the specific row in result set.
MySQL cursor is asensitive in nature that is it cannot create a copy of the table. It is faster than the other type of cursor i.e. insensitive cursor.