Views have a status associated with them. The status reflects the availability of the view for use by the database server. You can view the status of all views by selecting Views in the left pane of Sybase Central, and examining the values in the Status column in the right pane. Or, to see the status of a single view, right-click the view in Sybase Central and select Properties to examine the Status value.
Following are descriptions of the possible statuses:
VALID The view is valid and is guaranteed to be consistent with its definition. The database server can make use of this view without any additional work. An enabled view has the status VALID.
A VALID materialized view may not yet have data in it. This can occur if the materialized view was never initialized, or if initialization (or a refresh) failed. If the database server receives a request that references a materialized view that is in an uninitialized state, it attempts to initialize it. NoteA materialized view with stale data can still have the status VALID. The validity of a view relates to its schema being consistent with the schema(s) of the underlying objects, not to the staleness of data. |
INVALID This status does not apply to materialized views. An INVALID status occurs after a schema change to a referenced object where the change results in an unsuccessful attempt to enable the view. For example, suppose a view, v1, references a column, c1, in table t. If you alter t to remove c1, the status of v1 is set to INVALID when the database server tries to recompile the view as part of the ALTER operation that drops the column. In this case, v1 can recompile only after c1 is added back to t, or v1 is changed to no longer refer to c1. Views can also become INVALID if a table or view that they reference is dropped.
An INVALID view is different from a DISABLED view in that each time an INVALID view is referenced, for example by a query, the database server tries to recompile the view. If the compilation succeeds, the query proceeds. The view's status remains INVALID until it is explicitly enabled. If the compilation fails, an error is returned. When the database server internally enables an INVALID view, it issues a performance warning. In the SYSOBJECT system view, the value 2 indicates a status of INVALID.DISABLED Disabled views are not available for use by the database server for answering queries. Any query that attempts to use a disabled view returns an error.
A non-materialized view has this state if:you explicitly disable the view, for example by executing an ALTER VIEW ... DISABLE statement.
you disable a view (materialized or not) upon which the view depends.
you disable view dependencies for a table, for example by executing an ALTER TABLE...DISABLE VIEW DEPENDENCIES statement.