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

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Working with Database Objects » Working with views

Dropping views Next Page

Enabling and disabling views


The section describes enabling and disabling non-materialized views. For information on enabling and disabling materialized views, see Enabling and disabling materialized views.

You can control whether a view is available for use by the database server by enabling or disabling it. When you disable a view, the database server keeps the definition of the view in the database; however, the view is not available for use. 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 start using it.

If you disable a view, other views that reference it, directly or indirectly, are automatically disabled. Consequently, 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 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; otherwise, the view remains unchanged. 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 view, you must re-enable any other views that it references (if they are disabled).

To enable a view (Sybase Central)
  1. Connect to the database as a DBA user or as the owner of the view.

  2. Open the Views folder for that database.

  3. Select the view to enable.

  4. Choose File > Recompile and Enable.

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

  2. Open the Views folder for that database.

  3. Select the view to disable.

  4. Choose File > Disable.

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

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

  3. To disable a view (SQL)
    1. Connect to the database as a DBA user or as the owner of the view.

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

    3. Examples

      The following example disables a view called ViewSalesOrders.

      ALTER VIEW ViewSalesOrders DISABLE;

      The following example re-enables the ViewSalesOrders view.

      ALTER VIEW ViewSalesOrders ENABLE;
      See also