ALTER VIEW

Modify an existing view.

Syntax
      ALTER VIEW [schema.] view [ (column [,...n] ) ] 
         [WITH [ENCRYPTION] [SCHEMABINDING] [VIEW_METADATA] [,...n] ] 
            AS select_statement [;]
               [WITH CHECK OPTION]

Key
   view    Name of the view to be altered.

   column  Name to be used for a column in a view. 
           defaults to the same name as the column(s) in the SELECT statement.

   select_statement The view definition. This SELECT statement can reference
                    more than one table/view. Appropriate permissions are required.
                    cannot include a COMPUTE or ORDER BY clause (unless SELECT TOP..)

   CHECK OPTION   Enforce the criteria set with select_statement even
                  when modifying the data. This only affects the view not the underlying table.

   ENCRYPTION     Encrypts the text of the CREATE VIEW statement. 

   SCHEMABINDING  Bind the view to the schema of the underlying table or tables.

   VIEW_METADATA  Return metadata information about the view to client APIs
                  this allows updatable client-side cursors to address the view.

If a view is dropped and re-created, any GRANT or similar permission statements applied to the view must be re-entered.
Using ALTER VIEW will retain all the permission settings.

Example

ALTER VIEW emp_view
AS
SELECT c.FirstName, c.LastName, s.StaffID
FROM MySchema.Staff S JOIN MySchema.Customers c on c.CustomerID = c.StaffID ;
GO

# We always did feel the same, We just saw it from a different point of view# - Bob Dylan, Tangled Up In Blue

Related commands:

CREATE VIEW
DROP VIEW
sp_refreshview
sys.views
Equivalent Oracle command: ALTER VIEW


© Copyright SS64.com 1999-2014
Some rights reserved