Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Difference between View and Cursor in SQL

  • Difficulty Level : Medium
  • Last Updated : 19 Nov, 2021

1. View : 
A view is a virtual table that not actually exist in the database but it can be produced upon request by a particular user. A view is an object that gives the user a logical view of data from a base table we can restrict to what user can view by allowing them to see an only necessary column from the table and hide the other database details. View also permits users to access data according to their requirements, so the same data can be access by a different user in a different way according to their needs. 

2. Cursor : 
A cursor is a temporary work area created in memory for processing and storing the information related to an SQL statement when it is executed. The temporary work area is used to store the data retrieved from the database and manipulate data according to need. It contains all the necessary information on data access by the select statement. It can hold a set of rows called active set but can access only a single row at a time. There are two different types of cursors – 
1. Implicit Cursor 
2. Explicit Cursor 

Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course  by GeeksforGeeks.

Difference between View and Cursor in SQL :  

1.A view is a virtual table that gives logical view of data from base table.A cursor is a temporary workstation create in database server when SQL statement is executed.
2.Views are dynamic in nature which means any changes made in base table are immediately reflected in view.Cursor can be static as well as dynamic in nature.
3.We can perform CRUD operations on view like create, insert, delete and update.

There are some steps for creating a Explicit cursor – 

  • Declare the cursor in declaration section.
  • Open the cursor in execution section.
  • Fetch the cursor to retrieve data into PL/SQL variable.
  • Close the cursor to release allocated memory.


4.There are two types of view i.e. Simple View (created from single table) and Complex Cursor (created from multiple tables).Cursor has two types i.e. Implicit Cursor (pre-defined) and Explicit Cursor(user defined).
5.View is a database object similar to table so it can be used with both SQL and PL/SQL.Cursor is defined and used within the block of stored procedure which means it can be only used with PL/SQL.
6.General Syntax of Creating View : 
General Syntax of Creating View : 
CURSOR cursor_name IS select_statement; 
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!