Working with views

A View is a computed tables defined by the result set of its view definition, which is expressed as a SQL query. 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: regular views and materialized views.

The definition for each view in the database is stored in the ISYSVIEW system table. See SYSVIEW system view.

Documentation conventions

In the SQL Anywhere documentation, the term regular view is used to describe a view that is recomputed each time you reference the view, and the result set is not stored on disk. This is the most commonly used type of view. Most of the documentation refers to regular views.

The term materialized view is used to describe a view whose result set is precomputed and materialized on disk similar to the contents of a base table.

The meaning of the term view (by itself) in the documentation is context-based. When used in a section that is talking about common aspects of regular and materialized views, it refers to both regular and materialized views. If the term is used in documentation for materialized views, it refers to materialized views, and likewise for regular views.

Quick comparison between regular views, materialized views, and base tables

The following table compares regular views, materialized views, and base tables:

Capability Regular views Materialized views Base tables
Allow access permissions Yes Yes Yes
Allow SELECT Yes Yes Yes
Allow UPDATE Some No Yes
Allow INSERT Some No Yes
Allow DELETE Some No Yes
Allow dependent views Yes Yes Yes
Allow indexes No Yes Yes
Allow integrity constraints No No Yes
Allow keys No No Yes
Benefits of using views

Views let you tailor access to data in the database. Tailoring access serves several purposes:

  • Efficient resource use   Regular 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. Materialized views 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.


View dependencies
Working with regular views
Working with materialized views