CREATE OR REPLACE VIEW

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.

Tutorials dojo strip

SQL CREATE OR REPLACE VIEW Syntax

CREATE OR REPLACE VIEW view_name AS
SELECT column1 column2
FROM table_name
WHERE condition

SQL CREATE OR REPLACE VIEW Example

CREATE OR REPLACE VIEW FemalePatients AS
SELECT first_name last_name gender
FROM Patients
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.

SQL CREATE OR REPLACE VIEW Labs

Tutorials dojo strip
Scroll to Top