View (SQL)

This is an old revision of this page, as edited by JLaTondre (talk | contribs) at 01:13, 28 January 2006 (Correct link to company and not the prophetic oracle.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Originally, in database theory, a view is a read only virtual or logical table composed of the result set of a query. Unlike ordinary tables in a relational database, a view is not part of the physical schema: it is a dynamic, virtual table computed or collated from data in the database. Changing the data in a table alters the data shown in the view.

Views can provide advantages over tables;

  • They can subset the data contained in a table
  • They can join and simplify multiple tables into a single virtual view
  • Views can act as aggregated tables, where aggregated data (sum, average etc.) are calculated and presented as part of the data
  • Views can hide the complexity of data, for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table
  • Views do not incur any extra storage overhead
  • Depending on the sql engine used, views can provide extra security.

Various SQL engines have extended the views from read-only subsets of data. Oracle Corporation introduced the concept of materialised views; pre-executed, non-virtual views commonly used in data warehousing. They exist as a static snapshot of the data and may include data from remote sources. The accuracy of a materialised view depends on the frequency or trigger mechanisms behind its updates. The Microsoft equivalent of this, introduced in SQL Server 2000, is an indexed view.

See also