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 :
|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 sever 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 –
|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 :
CREATE VIEW “VIEW_NAME” AS “SQL Statement”;
|General Syntax of Creating View :
CURSOR cursor_name IS select_statement;
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Difference between Simple and Complex View in SQL
- What is Cursor in SQL ?
- Difference between Cursor and Trigger in DBMS
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between T-SQL and PL-SQL
- Difference between SQL and T-SQL
- Difference between Conflict and View Serializability
- SQL | Procedures in PL/SQL
- Difference between Static and Dynamic SQL
- Difference between SQL and NoSQL
- Difference between SQL and PLSQL
- Difference between DELETE and DROP in SQL
- Difference between MySQL and MS SQL Server
- Difference between JOIN and UNION in SQL
- Difference between COMMIT and ROLLBACK in SQL
- Difference between DROP and TRUNCATE in SQL
- Difference between Where and Having Clause in SQL
- Difference between order by and group by clause in SQL
- Difference Between Hadoop and SQL Performance
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.