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 dependent on the objects to which it refers.
The set of referenced objects for a given view includes all 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 v1 AS SELECT * FROM t1; CREATE VIEW v2 AS SELECT c3 FROM t2; 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.
Discuss this page in DocCommentXchange.
|Copyright © 2014, SAP AG or an SAP affiliate company. - SAP Sybase SQL Anywhere 16.0|