In a (relational) database, a view is a virtual table which gets its data from one or more tables and/or views through a SELECT query. The view does not store a copy of the data. Instead, each time data is requested from the view, the SELECT query is executed to fetch data from the underlying tables and/or views.

A view is created with the CREATE VIEW command. The basic syntax is CREATE VIEW name AS SELECT .... There are often restrictions on the SELECT clause. For example, ORDER BY is usually not allowed.

Usually, the view is read-only. Data modification is only possible if the SELECT query is simple, but sometimes it can be made possible by defining INSTEAD OF triggers (Microsoft SQL Server 2000) or rewrite rules (PostgreSQL).

Here is an example with two tables and a view with a SELECT query that joins the two tables.

"users" table
+---------------------------------+
| nickname | firstname | lastname |
+---------------------------------+
| johnny   | John      | Doe      |
| root     | System    | Admin    |
| steve    | Steve     | Smith    |
+---------------------------------+

"score" table
+---------------------------------+
| nickname | numarticles | points |
+---------------------------------+
| johnny   | 53          | 123    |
| root     | 0           | 0      |
| steve    | 12          | 72     |
+---------------------------------+

CREATE VIEW allinfo AS SELECT users.nickname, firstname,
 lastname, numarticles, points FROM users, score
 WHERE users.nickname = score.nickname

SELECT * FROM allinfo
+---------------------------------+----------------------+
| nickname | firstname | lastname | numarticles | points |
+---------------------------------+----------------------+
| johnny   | John      | Doe      | 53          | 123    |
| root     | System    | Admin    | 0           | 0      |
| steve    | Steve     | Smith    | 12          | 72     |
+---------------------------------+----------------------+