Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
Difference between From and Where Clause in SQL
Next article icon

Difference between View and Cursor in SQL

Last Updated : 06 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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 

Difference between View and Cursor in SQL :  

Sr.No. Basis of Comparison View Cursor
1. Terminology A view is a virtual table that gives logical view of data from base table. A CURSOR (CURrent Set of Records) is a temporary workstation created in the database server when the SQL statement is executed.
2. Nature 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. Operations 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.  Data retrieval Views are used to fetch or update data. Using cursors, data retrieval from the resultset takes place row by row.
4. Types There are two types of view i.e. Simple View (created from the single table) and Complex View (created from multiple tables). In simple view, group functions like COUNT(), MIN(), can be used whereas in complex view group functions cannot be used. Cursor has two types i.e. Implicit Cursor (pre-defined) and Explicit Cursor (user defined). Implicit cursor gets automatically created by Oracle whenever DML operations or SQL statement is executed whereas in explicit cursor user need to define them explicitly by giving a name.
5. Usage View is a database object similar to table so it can be used with both SQL and PL/SQL. The cursor is defined and used within the block of stored procedure which means it can be only used with PL/SQL.
6. Syntax General Syntax of Creating View : 
CREATE VIEW “VIEW_NAME” AS “SQL Statement”; 
General Syntax of Creating Explicit Cursor: 
CURSOR cursor_name IS select_statement; 
 


Next Article
Difference between From and Where Clause in SQL

M

meghasaki
Improve
Article Tags :
  • DBMS
  • Difference Between
  • SQL
  • DBMS-SQL

Similar Reads

  • Difference between Simple and Complex View in SQL
    A View in SQL as a logical subset of data from one or more tables. Views are used to restrict data access. A View contains no data of its own but it is like a window through which data from tables can be viewed or changed. The table on which a View is based is called BASE Tables. There are 2 types o
    2 min read
  • Difference between Cursor and Trigger in DBMS
    A cursor can be referred to as a pointer to the context. The context area is a memory area that Oracle creates when processing the SQL statement. The cursor is thus responsible for holding the rows that the SQL statement has returned. Therefore the PL/SQL controls the context area with the help of t
    4 min read
  • Difference between From and Where Clause in SQL
    1. FROM Clause: It is used to select the dataset which will be manipulated using Select, Update or Delete command.It is used in conjunction with SQL statements to manipulate dataset from source table.We can use subqueries in FROM clause to retrieve dataset from table. Syntax of FROM clause: SELECT *
    2 min read
  • Difference between SQLite and dBASE
    1. SQlite : SQLite is a software library that provides a relational database management system (RDBMS). It was designed by D. Richard Hipp on August 2000. The design goals of SQLite were to allow the program to be operated without installing a database management system(DBMS) or requiring a database
    2 min read
  • Difference Between View and Table
    In the world of database management systems (DBMS), views and tables are fundamental concepts that help in storing and managing data efficiently. While both terms are used frequently, they serve distinct purposes within a relational database. Understanding the difference between a view and a table i
    5 min read
  • Difference between DBMS and SQL
    1. Database management system (DBMS) :Database management system (DBMS) is a software that manage or organize the data in a database. We can arrange the data in a tabular form (i.e. in row or column). It helps the user to retrieve the data from the database.Best examples of DBMS are - MYSQL, ORACLE,
    2 min read
  • Difference between SQL and T-SQL
    SQL (Structured Query Language) is the standard language for managing and manipulating relational databases, enabling operations like querying, updating, and deleting data. T-SQL (Transact-SQL), an extension of SQL developed by Microsoft, adds advanced features and procedural capabilities specifical
    4 min read
  • Differences between SQL and SQLite
    1. Structured Query Language (SQL) : SQL stands for Structured Query Language. SQL can access, created and manage databases. SQL has became standard of American National Standards Institute. 2. SQLite : SQLite is software which provides relational database management system. SQLite lightweight in te
    2 min read
  • Difference between JOIN and UNION in SQL
    Pre-requisites: JOIN, UNION JOIN in SQL is used to combine data from many tables based on a matched condition between them. The data combined using the JOIN statement results in new columns. Consider the two tables: Boys Girls Example: sql> SELECT Boys.Name, Boys.Age, Girls.Address, FROM Boys INN
    2 min read
  • Difference between Implicit and Explicit Cursors
    In databases, cursors are essential tools that allow developers to retrieve and manipulate data row by row. Cursors provide a mechanism to process each record in a query result individually and making them useful when working with complex data sets. Cursors can be categorized into two types Implicit
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences