A view represents the definition of a SQL query as if it were another table in the database.
You can INSERT into and UPDATE, DELETE, and SELECT from a view just as you can any table.
We can use view to transform the data from multiple tables into what appears to be one table.
We can also use view to nest multiple outer joins against different tables.
The following code shows a DDL to Create an Authors Publications View.
CREATE OR REPLACE VIEW authors_publications as SELECT authors.id, authors.name, author_books.title, author_books.publish_date FROM authors, author_books WHERE authors.id = author_books.author_id;
The syntax for the CREATE VIEW statement is as follows:
CREATE [OR REPLACE] VIEW <view_name> AS <sql_select_statement>;
<view_name> is the name of the view <sql_select_statement> is a SQL SELECT statement against one or more tables in the database.
The brackets around the OR REPLACE clause denote that it is optional.
Using OR REPLACE preserves any privileges that exist on a view.