SELECT statements, as we've seen—particularly in the context of their use as subqueries—can be seen as returning tables. The SQL CREATE VIEW command allows us essentially to “freeze” this table as a view. This view can then be used almost as though it were a full-fledged table.
It is important to note that a view does not capture the results of the query but rather captures the SELECT statement that created it. Changes to the underlying tables will, therefore, be reflected in the view.
To create a view, we use the following basic format:
CREATE VIEW AS subquery
The subquery can be simple or arbitrarily complex. It can be used to create a virtual table that contains a subset of data in the actual table, for ...