SQL CREATE OR REPLACE VIEW Keyword
The CREATE OR REPLACE VIEW command is used in some SQL databases to update an existing view or create it if it does not exist. A view is a virtual table that stores a SELECT query and makes complex results easier to access.
SQL CREATE OR REPLACE VIEW Syntax
SQL
x
1
CREATE OR REPLACE VIEW view_name AS
2
SELECT column1 column2
3
FROM table_name
4
WHERE condition
SQL CREATE OR REPLACE VIEW Example
SQL
1
1
CREATE OR REPLACE VIEW FemalePatients AS
2
SELECT first_name last_name gender
3
FROM Patients
4
WHERE gender = 'F'
Note: This example will not work in SQLite including in the TechKubo playground. SQLite does not support CREATE OR REPLACE VIEW and will return a syntax error if you try this command.