Views are computed tables. You can use views to show database users exactly the information you want to present, in a format you can control. SQL Anywhere supports two types of views: non-materialized views, also referred to as just views, and materialized views. The two types of view differ in that non-materialized views are recomputed each time you invoke them. Materialized views are computed, stored on disk similar to a base table, and need their data refreshed periodically.
Since materialized views are stored and managed slightly differently, their tasks are documented separately. If you want information about materialized views, see Working with materialized views.
Views have a status associated with them that indicates whether the data they contain is up to date, and whether they are available to answer a query. See View status.
The following table highlights the things you can and cannot do with views and tables.
|Capability||Materialized views||Non-materialized views||Base tables|
|Allow access permissions||Yes||Yes||Yes|
|Allow SELECT on them||Yes||Yes||Yes|
|Allow dependent views||Yes||Yes||Yes|
|Allow integrity constraints||No||No||Yes|
Views let you tailor access to data in the database. Tailoring access serves several purposes:
Efficient resource use Non-materialized views do not require additional storage space for data; they are recomputed each time you invoke them. Materialized views require disk space, but do not need to be recomputed each time they are invoked. This can improve response time, particularly in environments where the database is large, and the database server processes frequent, repetitive requests to join the same tables.
Improved security By allowing access to only the information that is relevant.
Improved usability By presenting users and application developers with data in a more easily understood form than in the base tables.
Improved consistency By centralizing the definition of common queries in the database.
Using the WITH CHECK OPTION clause
Enabling and disabling views
Browsing data in views
Viewing system table data
Working with materialized views