In SQL, a view is a virtual table dependent on the outcome set of a SQL articulation.
A view contains lines and sections, much the same as a genuine table. The fields in a view are fields from at least one genuine table in the database.
You can include SQL capacities, WHERE, and JOIN proclamations to a view and present the information as though the information were originating from one single table.
Make VIEW Syntax Make VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition;
Note: A view dependably appears at date information! The database motor reproduces the information, utilizing the view's SQL explanation, each time a client questions a view.
SQL CREATE VIEW Examples
The accompanying SQL makes a view that demonstrates all clients from Brazil:
Model Make VIEW [Brazil Customers] AS SELECT CustomerName, ContactName FROM Customers WHERE Country = "Brazil";
We can question the view above as pursues:
Model
SELECT * FROM [Brazil Customers];
The accompanying SQL makes a view that chooses each item in the "Items" table with a cost higher than the normal cost: Model
Make VIEW [Products Above Average Price] AS
SELECT ProductName, Price FROM Products WHERE Price > (SELECT AVG(Price) FROM Products);
We can inquiry the view above as pursues:
Model
SELECT * FROM [Products Above Average Price];
SQL Updating a View
A view can be refreshed with the CREATE OR REPLACE VIEW direction.
SQL CREATE OR REPLACE VIEW Syntax
Make OR REPLACE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition;
The accompanying SQL includes the "City" segment to the "Brazil Customers" see:
Model
Make OR REPLACE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName, City FROM Customers WHERE Country = "Brazil"; SQL Dropping a View A view is erased with the DROP VIEW direction. SQL DROP VIEW Syntax DROP VIEW view_name;
The accompanying SQL drops the "Brazil Customers" see:
Model
DROP VIEW [Brazil Customers];
Very affordable projects!! And that to submit before deadlines. Thanks for helping me in my database project and raising my grades. I have been able to secure good marks in my internal assessment only because of you. Read More
Follow Us