SQLite Query Language: CREATE VIEW

Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Support |

# SQL As Understood By SQLite

[Top]

## CREATE VIEW

create-view-stmt:

> select-stmt:

> > common-table-expression:

> > compound-operator:

> > expr:

> > > literal-value:

> > > raise-function:

> > > type-name:

> > > > signed-number:

> > join-clause:

> > > join-constraint:

> > > join-operator:

> > ordering-term:

> > result-column:

> > table-or-subquery:

The CREATE VIEW command assigns a name to a pre-packaged SELECT statement. Once the view is created, it can be used in the FROM clause of another SELECT in place of a table name.

If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE" and "VIEW" then the view that is created is only visible to the database connection that created it and is automatically deleted when the database connection is closed.

If a <database-name> is specified, then the view is created in the named database. It is an error to specify both a <database-name> and the TEMP keyword on a VIEW, unless the <database-name> is "temp". If no database name is specified, and the TEMP keyword is not present, the VIEW is created in the main database.

You cannot DELETE, INSERT, or UPDATE a view. Views are read-only in SQLite. However, in many cases you can use an INSTEAD OF trigger on the view to accomplish the same thing. Views are removed with the DROP VIEW command.