SQL VIEW 关键字
CREATE VIEW
在 SQL 中,视图是一个基于 SQL 语句结果集的虚拟表。
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";
Query The View
We can query the view above as follows
示例
SELECT * FROM [Brazil Customers];
CREATE OR REPLACE VIEW
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";
DROP VIEW
The DROP VIEW
command deletes a view. (DROP VIEW 命令用于删除视图。)
The following SQL drops the "Brazil Customers" view (以下 SQL 语句删除 "Brazil Customers" 视图)
示例
DROP VIEW [Brazil Customers];