Use this statement to replace a view definition with a modified version. If SET HIDDEN or RECOMPILE is used, the view definition is not specified.
ALTER VIEW
[ owner.]view-name [ ( column-name, ... ) ] AS select-statement
[ WITH CHECK OPTION ]
ALTER VIEW
[ owner.]view-name { SET HIDDEN | RECOMPILE }
Syntax 1 The ALTER VIEW statement is identical in syntax to the CREATE VIEW statement except for the first word. The ALTER VIEW statement replaces the entire contents of the CREATE VIEW statement with the contents of the ALTER VIEW statement. Existing permissions on the view are maintained, and do not have to be reassigned. If a DROP VIEW followed by a CREATE VIEW is used, instead of ALTER VIEW, permissions on the view would have to be reassigned.
Syntax 2 You can use SET HIDDEN to scramble the definition of the associated view and cause it to become unreadable. The view can be unloaded and reloaded into other databases.
This setting is irreversible. If you will need the original source again, you must maintain it outside the database. |
If SET HIDDEN is used, debugging using the stored procedure debugger will not show the view definition, nor will it be available through procedure profiling.
The RECOMPILE clause is used to re-create the column definitions for an existing view. If the tables a view is based on are updated, you can use RECOMPILE to update the view definition. RECOMPILE is also used by the sa_recompile_views system procedure to update view definitions when rebuilding a database.
For more information, see .
| Caution If the SELECT statement defining the view contained an asterisk (*), the number of the columns in the view may change if columns have been added or deleted from the underlying tables. The names and data types of the view columns may also change. |
For information on the keywords and options, see .
Must be owner of the view or have DBA authority.
Automatic commit.
All procedures and triggers are unloaded from memory, so that any procedure or trigger that references the view reflects the new view definition. The unloading and loading of procedures and triggers can have a performance impact if you are regularly altering views.
SQL/92 Vendor extension.
SQL/99 Vendor extension.
Sybase Not supported by Adaptive Server Enterprise.