Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » SQL Anywhere Server - SQL Usage » Designing and Creating Databases » Working with database objects » Working with views


View dependencies

A view definition can refer to other objects including columns, tables, and other views. When a view makes a reference to another object, the view is called a referencing object and the object to which it refers is called a referenced object. Further, a referencing object is said to be dependent on the objects to which it refers.

The set of referenced objects for a given view includes all of the objects to which it refers either directly or indirectly. For example, a view can indirectly refer to a table, by referring to another view that references that table.

Consider the following set of tables and views:

CREATE TABLE t1 ( c1 INT, c2 INT );
CREATE TABLE t2( c3 INT, c4 INT );
CREATE VIEW v3 AS SELECT c1, c3 FROM v1, v2;

The following view dependencies can be determined from the definitions above:

  • View v1 is dependent on each individual column of t1, and on t1 itself.
  • View v2 is dependent on t2.c3, and on t2 itself.
  • View v3 is dependent on columns t1.c1 and t2.c3, tables t1 and t2, and views v1 and v2.

The database server keeps track of columns, tables, and views referenced by a given view. The database server uses this dependency information to ensure that schema changes to referenced objects do not leave a referencing view in an unusable state. The following tables explains how view dependencies affects regular and materialized views.

Dependencies and schema-altering changes
View dependency information in the catalog