Views

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.

Creating and Querying Views

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 ...

Get Java™ Oracle® Database Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.