ALTER VARIABLE

statementsupportedUDFs, procedures, tasks, alerts, scripting

docs.snowflake.com ↗

Object: VARIABLE

Modifies the properties of an existing schema variable.

Syntax

supportedpartialnot supportednot scored

ALTER VARIABLE [ IF EXISTS ] <name> RENAME TO <new_name>

ALTER VARIABLE [ IF EXISTS ] <name> SET DEFAULT <default_value>

ALTER VARIABLE [ IF EXISTS ] <name> DROP DEFAULT

ALTER VARIABLE [ IF EXISTS ] <name> SET COMMENT = '<string_literal>'

ALTER VARIABLE [ IF EXISTS ] <name> UNSET COMMENT

Parameters

NameRequiredDescription
nameSpecifies the identifier for the variable to alter. The identifier can be qualified with the schema name or with both the database and schema names.
RENAME TO new_nameSpecifies the new identifier for the variable; must be unique within the schema. You can move the object to a different database and/or schema while optionally renaming the object. To do so, specify a qualified new_name value that includes the new database and/or schema name in the form db_name.schema_name.object_name or schema_name.object_name, respectively. Note The destination database and/or schema must already exist. In addition, an object with the same name cannot already exist in the new location; otherwise, the statement returns an error. Moving an object to a managed access schema is prohibited unless the object owner (that is, the role that has the OWNERSHIP privilege on the object) also owns the target schema. When a variable is renamed, any session variables that shadow it are unaffected because session variables and schema variables are resolved by name independently.
SET DEFAULT default_valueChanges the default value for the variable. The expression is evaluated at statement execution time and must be compatible with the variable’s declared data type. To reset a variable’s current value to the new default, use SET schema.name = DEFAULT.
DROP DEFAULTRemoves the default value from the variable. The variable’s current value is unchanged; only the stored default is cleared.
SET COMMENT = 'string_literal'Sets or replaces the comment for the variable.
UNSET COMMENTRemoves the comment from the variable.

Usage notes

Access control requirements

A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes OWNERSHIP | Variable | OWNERSHIP is a special privilege on an object that is automatically granted to the role that created the object, but can also be transferred using the GRANT OWNERSHIP command to a different role by the owning role (or any role with the MANAGE GRANTS privilege). Note that in a managed access schema, only the schema owner (i.e. the role with the OWNERSHIP privilege on the schema) or a role with the MANAGE GRANTS privilege can grant or revoke privileges on objects in the schema, including future grants. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

See also

Referenced by