Description
The SQL keyword CREATE OR REPLACE VIEW is used to create or update a view.
- A view is a virtual table based on the result set of an SQL statement.
- A new view is created if it doesn't exist with that name.
- An existing view is updated if it already exists with the same name.
The below SQL statement creates (if not existing) or updates (if already exists) a view.
CREATE OR REPLACE VIEW [Spain Customers] AS
SELECT customer_name, address, city
FROM customers
WHERE country = "Spain";
The below SQL statement returns the data on the view.
SELECT * FROM [Spain Customers];