In SQL, a view is a virtual table based on the result set of an SQL statement.
The CREATE VIEW
command creates a view.
The following SQL creates a view that selects all customers from Brazil:
CREATE VIEW [Brazil Customers] AS
SELECT CustomerName, ContactName
FROM Customers
WHERE Country = "Brazil";
We can query the view above as follows:
SELECT * FROM [Brazil Customers];
The CREATE OR REPLACE VIEW
command updates a view.
The following SQL adds the "City" column to the "Brazil Customers" view:
CREATE OR REPLACE VIEW [Brazil Customers] AS
SELECT CustomerName, ContactName, City
FROM Customers
WHERE Country = "Brazil";
The DROP VIEW
command deletes a view.
The following SQL drops the "Brazil Customers" view:
DROP VIEW [Brazil Customers];
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!