INSENSITIVE is an optional cursor attribute in the ISO SQL standard. When a cursor is declared INSENSITIVE, the database engine materializes or snapshots the query result at the moment the cursor is opened. Subsequent inserts, updates, or deletes committed by other transactions on the underlying tables are not visible through FETCH operations issued on that cursor. Updates performed through the cursor itself remain visible, allowing positioned UPDATE or DELETE statements to succeed on the buffered rows. Because the engine may store the snapshot in temporary space, INSENSITIVE cursors often consume more memory or disk than their sensitive counterparts. Some vendors ignore the keyword or silently convert it to an internal cursor type that matches their implementation limits, so always verify vendor documentation.
- cursor_name
(identifier) - Name assigned to the cursor.- select_statement
(SQL query) - Defines the result set over which the cursor will iterate.- SCROLL
(optional) - keyword - Allows fetching rows in any direction.CURSOR, SCROLL, NO SCROLL, WITH HOLD, STATIC, DYNAMIC, SNAPSHOT ISOLATION
SQL-92 (ISO/IEC 9075:1992)
If the vendor ignores the keyword, the cursor behaves as the default cursor type for that dialect, typically one that can see committed changes. Always test behavior in your target DBMS.
It guarantees repeatable reads only through that cursor. Other queries executed in the same transaction can still see concurrent changes unless the isolation level also blocks them.
Yes. Rows fetched through the cursor can still be updated or deleted using positioned UPDATE and DELETE statements. Those changes become visible within the cursor.
Yes in databases that support both features. WITH HOLD keeps the cursor open after COMMIT, while INSENSITIVE keeps its result set stable.