SQL CREATE VIEW Keyword
The CREATE VIEW command is used to define a view. A view is a virtual table that stores a predefined SELECT query. Views make complex data easier to read and reuse.
SQL CREATE VIEW Syntax
SQL
x
1
CREATE VIEW view_name AS
2
SELECT column1 column2
3
FROM table_name
4
WHERE condition
SQL CREATE VIEW Syntax
This creates a view named FemalePatients
that displays the first name, last name, and gender of all patients whose gender is F
.
SQL
1
1
CREATE VIEW FemalePatients AS
2
SELECT first_name, last_name, gender
3
FROM Patients
4
WHERE gender = 'F';

SQL CREATE VIEW Query the View Example
After creating the view, you can retrieve data from it like a regular table.
This will return all rows from the view showing only female patients.
SQL
1
1
SELECT * FROM FemalePatients;
