English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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 selecting all customers from Brazil:
CREATE VIEW [Brazil Customers] AS SELECT CustomerName, ContactName FROM Customers WHERE Country = "Brazil";
We can query the following views:
SELECT * FROM [Brazil Customers];
The CREATE OR REPLACE VIEW command will update the 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 will delete a view.
The following SQL deletes the 'Brazil Customers' view:
DROP VIEW [Brazil Customers];