Creating Views

Here's the simplified syntax of a view definition statement:

CREATE VIEW view_name [(column_name [, column_name]...)]
AS
SELECT_statement
  • Follow your system's rules for identifiers when you name the view.

  • Specify view column names if the column is calculated or if multiple columns have the same name. Otherwise, columns inherit names from the SELECT clause.

  • Define the columns and rows of the view in the SELECT statement.

The following example creates a view that displays the names of authors who live in Oakland, California, and their books. The view is named oaklanders. Its SELECT statement pulls data from three tables.

SQL
 create view oaklanders (FirstName, LastName, Book) as select au_fname, au_lname, title from authors, titles, ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition 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.