Introduction
In this blog, I will explain the SQL View. The view is used for retrieving data as well as updating or deleting rows. Rows updated or deleted in the view are updated or deleted in the table that the view was created with. It should also be noted that as data in the original table changes, so does data in the views. The results of using a view are not permanently stored in the database.
Syntax
- CREATE VIEW VIEW_NAME
- AS
- SELECT COLUMN1,COLUMN2 FROM TB_NAME;
Types of view
Simple view
- It contains only a single base table or created from only one table.
- We cannot use group functions.
- DML operations can be performed through a simple view.
- Does not include NOT NULL columns from base tables.
Complex view
- This view contains more than one base table or is created through more than one table.
- We can use group functions.
- DML operations could not be performed through a complex view.
- NOT NULL columns not selected by simple view can be included in a complex view.