How to Create View in SQL?
Syntax of CREATE VIEW in SQL-
CREATE VIEW <view_name> AS
SELECT column_name1,..column_nameN
FROM <table_name> WHERE <condition(s)>;
Example of VIEW in SQL-
CREATE VIEW [Germany Customers] AS
SELECT CustomerName, ContactName
FROM Customers
WHERE Country= ‘Germany’; –To create view Germany Customers
SELECT * FROM [Germany Customers]; –To execute or query the view
How To Delete View in SQL?
Syntax to delete view in SQL-
DROP VIEW view_name;
Example to delete view in SQL–
DROP VIEW [Germany Customers];
How to update view in SQL?
CREATE OR REPLACE VIEW <view_name> AS
SELECT column_name1,..column_nameN
FROM <table_name> WHERE <condition(s)>;
Example of CREATE OR REPLACE VIEW-
CREATE OR REPLACE VIEW [Germany Customers] AS
SELECT CustomerName, ContactName
FROM Customers
WHERE Country= ‘Germany’; –To create view Germany Customers