A view is a virtual table that is derived from one or more tables. A view is essentially a stored query. You can access a view to query data from the tables on which the view is based. This topic describes the concepts, benefits, and characteristics of views. A view retrieves data from the tables on which it is based. These tables are called base tables. Base tables can be tables or other views. All operations performed on a view need to access its base tables. You can use views in most scenarios where you use tables.
Benefits
Views enable you to customize the presentation of data for different types of users. The following list describes the benefits of views:
- You can define frequently queried data as views to simplify operations. Database queries may use aggregate functions, display information of additional fields, and relate to other tables. As a result, the SQL statements can be rather complex. To avoid frequently executing these queries, you can create a view to simplify the query process. To obtain the desired query result after the view is created, execute the
SELECT * FROM view_namestatement. - You can query and modify only visible data in the view. This improves data security. A view is a data set that is automatically updated based on changes in the base tables. As a virtual table, a view does not physically exist and displays only the result set of a query. Therefore, you can choose not to display sensitive fields of the base tables to users.
- A view is logically independent of the data structure of the base tables. Views allow applications to be independent of database tables. If views are not used, applications depend on real tables. After views are introduced, applications depend on views but not on real tables and are immune to changes in table schema.
Characteristics
Unlike tables, views do not occupy storage space or store data. A view is defined by a query that extracts or derives data from the referenced base tables. Therefore, a view requires no storage other than the storage for the query that defines the view in the data dictionary.