Using Views

A view is a virtual table whose contents are defined by a query. A query is a set of instructions that retrieves and displays data from a database. In SQL Server, you create a query using the SELECT statement.

A view looks like a real table ¾ with a set of named columns and rows of data. However, a view does not exist as a stored set of data values in a database. Instead, the rows and columns of data in a view come from base tables and are produced by the query that defines the view.

Here is a view based on two tables:

Views provide security by controlling the data users can see. Views allow users to work with a database in the form they are used to, even when changes occur to the structure of the database.

A view looks exactly like any other database table. You can display it and operate on it almost as you can any other table. Transact-SQL enhances standard SQL so that there are no restrictions on querying through views and few restrictions on modifying them.

The definition of a view (the base tables from which it is derived) is stored in the database. The data that you view is stored in only one place: in the base tables. No separate copies of data are associated with this stored definition.

When you modify the data you see in a view, you are actually changing data in the underlying base tables. Changes to data in the underlying base tables are automatically reflected in the views derived from them.