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
CREATE VIEW view_name AS SELECT column1 column2 FROM table_name 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
.
CREATE VIEW FemalePatients AS SELECT first_name, last_name, gender FROM Patients 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.
SELECT * FROM FemalePatients;
