ALTER SECRET
statementsupportedIntegrations, network & secretsModifies the properties of an existing secret.
Syntax
supportedpartialnot supportednot scored
OAuth with client credentials flow
ALTER SECRET [ IF EXISTS ] <name> SET [ OAUTH_SCOPES = ( '<scope_1>' [ , '<scope_2>' ... ] ) ]
[ COMMENT = '<string_literal>' ]
ALTER SECRET [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER SECRET [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
OAuth with authorization code grant flow
ALTER SECRET [ IF EXISTS ] <name> SET [ OAUTH_REFRESH_TOKEN = '<token>' ]
[ OAUTH_REFRESH_TOKEN_EXPIRY_TIME = '<string_literal>' ]
[ COMMENT = '<string_literal>' ]
ALTER SECRET [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER SECRET [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Available to all accounts.
ALTER SECRET [ IF EXISTS ] <name> SET [ API_AUTHENTICATION = '<cloud_provider_security_integration>' ]
[ COMMENT = '<string_literal>' ]
ALTER SECRET [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER SECRET [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Basic authentication
ALTER SECRET [ IF EXISTS ] <name> SET [ USERNAME = '<username>' ]
[ PASSWORD = '<password>' ]
[ COMMENT = '<string_literal>' ]
ALTER SECRET [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER SECRET [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Generic string
ALTER SECRET [ IF EXISTS ] <name> SET [ SECRET_STRING = '<string_literal>' ]
[ COMMENT = '<string_literal>' ]
ALTER SECRET [ IF EXISTS ] <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]
ALTER SECRET [ IF EXISTS ] <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Parameters
| Name | Required | Description |
|---|---|---|
name | String that specifies the identifier (i.e. name) for the secret, must be unique in your schema. | |
SET ... | Specifies one (or more) parameters to set (separated by blank spaces, commas, or new lines). | |
OAUTH_SCOPES = ( 'scope_1' [ , 'scope_2' ... ] ) | Specifies a comma-separated list of scopes to use when making a request from the OAuth server by a role with USAGE on the integration during the OAuth client credentials flow. This list must be a subset of the scopes defined in the OAUTH_ALLOWED_SCOPES property of the security integration. If the OAUTH_SCOPES property values are not specified, the secret inherits all of the scopes that are specified in the security integration. | |
SET ... | Specifies one (or more) parameters to set (separated by blank spaces, commas, or new lines). | |
TYPE = CLOUD_PROVIDER_TOKEN | Specifies that this is secret for use with a cloud provider, such as Amazon Web Services (AWS). | |
API_AUTHENTICATION = 'cloud_provider_security_integration' | Specifies the name value of the Snowflake security integration that connects Snowflake to a cloud provider. | |
name | String that specifies the identifier (i.e. name) for the secret, must be unique in your schema. | |
SET ... | Specifies one (or more) parameters to set (separated by blank spaces, commas, or new lines). | |
OAUTH_REFRESH_TOKEN = 'token' | Specifies the token as a string that is used to obtain a new access token from the OAuth authorization server when the access token expires. | |
OAUTH_REFRESH_TOKEN_EXPIRY_TIME = 'string_literal' | Specifies the timestamp as a string when the OAuth refresh token expires. | |
name | String that specifies the identifier (i.e. name) for the secret, must be unique in your schema. | |
SET ... | Specifies one (or more) parameters to set for the session (separated by blank spaces, commas, or new lines). | |
USERNAME = 'username' | Specifies the username value to store in the secret. Specify this property value when using a secret for basic authentication (i.e. the secret is TYPE = PASSWORD). | |
PASSWORD = 'password' | Specifies the password value to store in the secret. Specify this property value when using a secret for basic authentication (i.e. the secret is TYPE = PASSWORD). | |
name | String that specifies the identifier (i.e. name) for the secret, must be unique in your schema. | |
SET ... | Specifies one (or more) parameters to set (separated by blank spaces, commas, or new lines). | |
SECRET_STRING = 'string_literal' | Specifies the string to store in the secret. The string can be an API token or a string of sensitive value that can be used in the handler code of a UDF or stored procedure. For details, see Creating and using an external access integration. You should not use this property to store any kind of OAuth token; use one of the other secret types for your OAuth use cases. | |
SET ... | Specifies one (or more) parameters to set for the session (separated by blank spaces, commas, or new lines). | |
COMMENT = 'string_literal' | String (literal) that specifies a comment for the secret. Default: No value | |
TAG tag_name = 'tag_value' [ , tag_name = 'tag_value' , ... ] | Specifies the tag name and the tag string value. The tag value is always a string, and the maximum number of characters for the tag value is 256. For information about specifying tags in a statement, see Tag quotas. |
Usage notes
- ALTER SECRET doesn’t support UNSET COMMENT. To remove the comment from a secret, set it to an empty string: Copy code ALTER SECRET <name> SET COMMENT = '';
- Regarding metadata:
- Attention
- Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes MODIFY | Secret | Required to update OAuth tokens in a secret using SYSTEM$START_OAUTH_FLOW and SYSTEM$FINISH_OAUTH_FLOW. Also required to alter other secret properties via ALTER SECRET. OWNERSHIP | Secret | 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). Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. 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.