VIEW


A view statement is nothing more than a saved SQL query. A view statement can also be considered as a virtual table.
In SQL, CREATE VIEW is used to create a virtual table from the given query.
A view statement can contain all rows of a table or select rows from a table.
View can be created one or many tables.

Types of views :-
  • Read only view : used only to read .
  • updatable view : used to read and update the data.
Syntax :-

CREATE VIEW view_name AS

SELECT column1, column2,.........columnN

FROM table_name

WHERE condition;

Example : Let's see how to create VIEW in table.

Query :

CREATE VIEW customers_VIEW AS

SELECT Name, Address

FROM customers;

Output : 

Now, you can see VIEW is created in customers table. This view would be used to have customer name and address from the CUSTOMERS table.

Now, Use SQL query and see output.
Query :
SELECT * FROM customers_VIEW;
Output :

DROP VIEW


We can used  DROP VIEW statement in table. and can , remove the drop conditions.

Syntax :-
DROP VIEW view_name;
Query :
DROP  VIEW  Customers_VIEW;
Output :