View Explained In SQL Server

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
  1. CREATE VIEW VIEW_NAME  
  2. AS  
  3. SELECT COLUMN1,COLUMN2 FROM TB_NAME;  
Types of view
  1. Simple view
  2. Complex view
Simple view
  1. It contains only a single base table or created from only one table.
  2. We cannot use group functions.
  3. DML operations can be performed through a simple view.
  4. Does not include NOT NULL columns from base tables.
Complex view
  1. This view contains more than one base table or is created through more than one table.
  2. We can use group functions.
  3. DML operations could not be performed through a complex view.
  4. NOT NULL columns not selected by simple view can be included in a complex view.