On this page

    ALTER VIEW

    Change an existing view.

    Syntax
    -- Set a Column-Masking Policy
    ALTER VIEW [ IF EXISTS ] <view_name>
      MODIFY COLUMN <column_name>
      SET MASKING POLICY <function_name> ( <column_name> [, ... ] )
    
    -- Unset a Column-Masking Policy
    ALTER VIEW [ IF EXISTS ] <view_name>
      MODIFY COLUMN <column_name>
      UNSET MASKING POLICY <function_name>
    
    -- Add or Remove a Row-Access Policy
    ALTER VIEW [ IF EXISTS ] <view_name>
      { ADD | DROP } ROW ACCESS POLICY <function_name> ( <column_name> [, ... ] )
    

    Parameters

    <view_name>

    String

    The path of the view that you want to create. The name of the view should be unique. The view can be in your home space.


    MODIFY COLUMN <column_name>

    String

    Specifies the column to which the masking policy will apply and mask data for. The UDF serving as the masking policy must accept and return the same data type as the column it is masking.


    <function_name>

    String

    Specifies the function to use with this security policy. If a function with this name does not exist, then the affected table/view will not be reachable until the policy is dropped or a UDF created.


    Examples

    Set a column-masking policy on multiple columns
    ALTER VIEW customers
        MODIFY COLUMN ssn_col
        SET MASKING POLICY protect_ssn (ssn_col, region)
    
    Unset a column-masking policy
    ALTER VIEW customers
        MODIFY COLUMN ssn_col
        UNSET MASKING POLICY protect_ssn
    
    Add a row-access policy to a view
    ALTER VIEW customers
      ADD ROW ACCESS POLICY state_policy ( state_col )
    
    Remove row-access policy from a view
    ALTER VIEW customers
      DROP ROW ACCESS POLICY protect_ssn (ssn_col)