Enable and disable regular views

The section describes enabling and disabling regular views. For information about enabling and disabling materialized views, see Enable and disable materialized views.

You can control whether a regular view is available for use by the database server by enabling or disabling it. When you disable a regular view, the database server keeps the definition of the view in the database; however, the view is not available for use in satisfying a query. If a query explicitly references a disabled view, the query fails and an error is returned. Once a view is disabled, it must be explicitly re-enabled so that the database server can use it.

If you disable a view, other views that reference it, directly or indirectly, are automatically disabled. So, once you re-enable a view, you must re-enable all other views that were dependent on the view when it was disabled. You can determine the list of dependent views before disabling a view using the sa_dependent_views system procedure. See sa_dependent_views system procedure.

When you enable a regular view, the database server recompiles it using the definition stored for the view in the database. If compilation is successful, the view status changes to VALID. An unsuccessful recompile could indicate that the schema has changed in one or more of the referenced objects. If so, you must change either the view definition or the referenced objects until they are consistent with each other, and then enable the view.

Note

Before you enable a regular view, you must re-enable and disabled views that it references.

You can grant permissions on disabled objects. Permissions to disabled objects are stored in the database and become effective when the object is enabled.

To disable a regular view (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as the owner of the regular view.

  2. In the left pane, double-click Views.

  3. Right-click the view and choose Disable.

To disable a regular view (SQL)
  1. Connect to the database as a user with DBA authority, or as the owner of the regular view.

  2. Execute an ALTER VIEW ... DISABLE statement.

Example

The following example disables a regular view called ViewSalesOrders owned by GROUPO.

ALTER VIEW GROUPO.ViewSalesOrders DISABLE;
To enable a regular view (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as the owner of the regular view.

  2. In the left pane, double-click Views.

  3. Right-click the view and choose Recompile And Enable.

To enable a regular view (SQL)
  1. Connect to the database as a user with DBA authority, or as the owner of the regular view.

  2. Execute an ALTER VIEW ... ENABLE statement.

Example

The following example re-enables the regular view called ViewSalesOrders owned by GROUPO.

ALTER VIEW GROUPO.ViewSalesOrders ENABLE;
See also