Oracle7 Server SQL Reference

Contents Index Home Previous Next

ALTER VIEW

Purpose

To recompile a view.

Prerequisites

The view must be in your own schema or you must have ALTER ANY TABLE system privilege.

If you are using Trusted Oracle7 in DBMS MAC mode, your DBMS label must match the view's creation label or you must satisfy one of the following criteria:

Syntax

Keywords and Parameters

schema

is the schema containing the view. If you omit schema, Oracle7 assumes the view is in your own schema.

view

is the name of the view to be recompiled.

COMPILE

causes Oracle7 to recompile the view. The COMPILE keyword is required.

Usage Notes

You can use the ALTER VIEW command to explicitly recompile a view that is invalid. Explicit recompilation allows you to locate recompilation errors before runtime. You may want to explicitly recompile a view after altering one of its base tables to ensure that the alteration does not affect the view or other objects that depend on it.

When you issue an ALTER VIEW statement, Oracle7 recompiles the view regardless of whether it is valid or invalid. Oracle7 also invalidates any local objects that depend on the view. For more information, see the "Dependencies Among Schema Objects" chapter of Oracle7 Server Concepts.

Note: This command does not change the definition of an existing view. To redefine a view, you must use the CREATE VIEW command with the OR REPLACE option.

Example

To recompile the view CUSTOMER_VIEW, issue the following statement:

ALTER VIEW customer_view
 	COMPILE 

If Oracle7 encounters no compilation errors while recompiling CUSTOMER_VIEW, CUSTOMER_VIEW becomes valid. If recompiling results in compilation errors, Oracle7 returns an error and CUSTOMER_VIEW remains invalid.

Oracle7 also invalidates all dependent objects. These objects include any procedures, functions, package bodies, and views that reference CUSTOMER_VIEW. If you subsequently reference one of these objects without first explicitly recompiling it, Oracle7 recompiles it implicitly at runtime.

Related Topics

CREATE VIEW command [*]


Contents Index Home Previous Next