What Is a View?

3 4

A view is a virtual table that is defined by a query consisting of a SELECT statement. This virtual table is made up of data from one or more real tables, and to users, a view looks like an actual table. In fact, a view can be treated exactly like a regular table. Users can reference these virtual tables in Transact-SQL (T-SQL) statements in the same way tables are referenced. SELECT, INSERT, UPDATE, and DELETE operations can be performed on a view.

In reality, a view is stored simply as a predefined SQL statement. When the view is accessed, the SQL Server query optimizer merges the currently executing SQL statement with the query that was used to define the view.

The advantage of using views is that views with different attributes can be created without having to duplicate the data. Views are useful in a number of situations. As we will see later in this chapter, they can be used for data security, for ease of presentation of data, and for logical presentation of data. They can also be used to merge partitioned data.



Microsoft SQL Server 2000 Administrator's Companion
Microsoft SQL Server 2000 Administrators Companion
ISBN: B001HC0RPI
EAN: N/A
Year: 2005
Pages: 264

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net