ALTER SNAPSHOT SET --- Deprecated

Modifies the properties for a snapshot set. This operation can be one of the following:

  • Taking a new backup that becomes part of the snapshot set.

  • Removing an old backup from the snapshot set.

  • Suspending or resuming the scheduled backups and scheduled snapshot deletion that are specified by the snapshot policy.

  • Applying a snapshot policy to a snapshot set that doesn't already have a policy.

  • Adding or removing a legal hold for a specific snapshot within the snapshot set.

  • Specifying or removing a comment for the snapshot set.

另请参阅:

CREATE SNAPSHOT SET --- Deprecated, DROP SNAPSHOT SET --- Deprecated, SHOW SNAPSHOT SETS --- Deprecated

语法

ALTER SNAPSHOT SET <name> ADD SNAPSHOT

ALTER SNAPSHOT SET <name> APPLY SNAPSHOT POLICY <policy_name> [ FORCE ]

ALTER SNAPSHOT SET <name> SUSPEND SNAPSHOT [ { CREATION | EXPIRATION } ] POLICY

ALTER SNAPSHOT SET <name> RESUME SNAPSHOT [ { CREATION | EXPIRATION } ] POLICY

ALTER SNAPSHOT SET <name> DELETE SNAPSHOT IDENTIFIER '<snapshot_id>'

ALTER SNAPSHOT SET <name> MODIFY SNAPSHOT IDENTIFIER '<snapshot_id>' { ADD | REMOVE } LEGAL HOLD

ALTER SNAPSHOT SET <name> SET COMMENT = '<string_literal>'

ALTER SNAPSHOT SET <name> UNSET COMMENT

ALTER SNAPSHOT SET <name> SET TAG <tag_name> = '<tag_value>' [ , <tag_name> = '<tag_value>' ... ]

ALTER SNAPSHOT SET <name> UNSET TAG <tag_name> [ , <tag_name> ... ]
Copy

参数

name

Specifies the identifier for the snapshot set.

如果标识符包含空格或特殊字符,则整个字符串必须放在双引号内。放在双引号内的标识符也区分大小写。

有关更多信息,请参阅 标识符要求

ADD SNAPSHOT

Manually create a snapshot in the set. If the snapshot policy doesn't include a schedule for taking new backups, this is how you make a new backup of the table, schema, or database that's included in the snapshot set. You can also make new backups in the snapshot set at any time even when backups happen on a regular schedule.

APPLY SNAPSHOT POLICY policy_name [ FORCE ]

Specifies the snapshot policy to attach to the snapshot set.

The FORCE option overwrites an existing policy on a snapshot set. You can only use this option if the old policy doesn't have a retention lock.

重要

Applying a snapshot policy with a retention lock to a snapshot set is irreversible. Due to the strong guarantees that are needed for regulatory compliance, after you put a retention lock on a snapshot set, you can't revoke the lock. Snowflake support also can't revoke such a retention lock. Plan carefully before you set a retention lock on a snapshot set with a long expiration period, to avoid unexpected storage charges for undeletable snapshot sets, and the schemas and databases that contain them.

If a Snowflake organization is deleted, the organization is no longer a Snowflake customer. In this case, Snowflake deletes all snapshots, including those with retention locks. Deleting a Snowflake organization requires the involvement of Snowflake support. It isn't something that an administrator can do by accident.

SUSPEND SNAPSHOT [ { CREATION | EXPIRATION } ] POLICY

Suspend a snapshot policy in the snapshot set. You can suspend the entire snapshot policy, or only creation or expiration operations. When you specify SUSPEND SNAPSHOT POLICY without the CREATION or EXPIRATION keywords, Snowflake suspends both the creation and expiration aspects of the policy. For more information, see 暂停备份集上的备份策略.

RESUME SNAPSHOT [ { CREATION | EXPIRATION } ] POLICY

Resume a suspended snapshot policy in the set. You can resume the entire snapshot policy, or only creation or expiration operations. When you specify RESUME SNAPSHOT POLICY without the CREATION or EXPIRATION keywords, Snowflake resumes both the creation and expiration aspects of the policy. For more information, see 恢复备份集上的备份策略.

DELETE SNAPSHOT IDENTIFIER 'snapshot_id'

Delete a snapshot in the snapshot set by ID. The snapshot ID is a UUID value, in the format returned by the UUID_STRING function. Snowflake only allows deleting the oldest snapshot from the snapshot set. For more information, see 从备份集中删除备份.

MODIFY SNAPSHOT IDENTIFIER 'snapshot_id' { ADD | REMOVE } LEGAL HOLD

Adds or removes a legal hold from a specified snapshot within the snapshot set. For more information about legal holds for WORM snapshots, see 法律保留. For examples of using this clause, see 添加和移除法律保留.

SET COMMENT = 'string_literal'

Associate a comment with the snapshot set.

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.

UNSET ...

Specifies one (or more) properties and/or parameters to unset for the snapshot set, which resets them to the defaults:

  • property_name

  • param_name

    • COMMENT

    • TAG tag_name [ , tag_name ... ]

You can reset multiple properties/parameters with a single ALTER statement; however, each property/parameter must be separated by a comma. Also, when resetting a property/parameter, you only specify the name; no value is required.

访问控制要求

用于执行此操作的 角色 必须至少具有以下 权限

权限

描述

OWNERSHIP

The role used to modify a snapshot set must have the OWNERSHIP privilege on the snapshot set.

APPLY SNAPSHOT RETENTION LOCK

If the snapshot policy applied to a snapshot set includes a retention lock, the role used to apply the policy must have this privilege on the account.

APPLY LEGAL HOLD

This account privilege grants the ability to add or remove a legal hold from a snapshot. This privilege is only needed for the ADD LEGAL HOLD and REMOVE LEGAL HOLD clauses. By default, the ACCOUNTADMIN role has this privilege.

APPLY

Only a user with this privilege on the snapshot policy can use the ALTER SNAPSHOT SET command with the APPLY SNAPSHOT POLICY clause to add the snapshot policy to a snapshot set that already exists.

These privileges are required on the currently active primary role, not a secondary role.

有关创建具有指定权限集的自定义角色的说明,请参阅 创建自定义角色

有关对 安全对象 执行 SQL 操作的相应角色和权限授予的一般信息,请参阅 访问控制概述

使用说明

  • 关于元数据:

    注意

    客户应确保在使用 Snowflake 服务时,不会将个人数据(用户对象除外)、敏感数据、出口管制数据或其他受监管数据作为元数据输入。有关更多信息,请参阅 Snowflake 中的元数据字段

重要

If the snapshot policy has a retention lock applied to it, and there are any unexpired snapshots in the snapshot set, then you can't delete the snapshot set. In that case, you must wait for all the snapshots in the set to expire. This restriction applies even to privileged roles such as ACCOUNTADMIN, and to Snowflake support. For that reason, be careful when specifying retention lock and a long expiration period in a snapshot policy.

示例

Manually add a snapshot to snapshot set t1_snapshots:

ALTER SNAPSHOT SET t1_snapshots
  ADD SNAPSHOT;
Copy

Update the snapshot policy for snapshot set t1_snapshots:

ALTER SNAPSHOT SET t1_snapshots
  APPLY SNAPSHOT POLICY daily_snapshot_policy;
Copy

Suspend a snapshot policy on the snapshot set t1_snapshot:

ALTER SNAPSHOT SET t1_snapshots
  SUSPEND SNAPSHOT POLICY;
Copy

Resume a snapshot policy on the snapshot set t1_snapshots:

ALTER SNAPSHOT SET t1_snapshots
  RESUME SNAPSHOT POLICY;
Copy

To find the snapshot identifier to use with the ADD LEGAL HOLD and REMOVE LEGAL HOLD clauses, you typically use the SHOW SNAPSHOTS command to list the eligible snapshots and their creation times. The following example shows how you might list the appropriate snapshots, add a legal hold to one specific snapshot, and later remove that legal hold. Substitute your own role name, snapshot set name, and snapshot identifier.

USE ROLE my_legal_hold_role; -- use a role that has the APPLY LEGAL HOLD privilege
SHOW SNAPSHOTS IN SNAPSHOT SET my_db_snapshot_set
  ->> SELECT "created_on", "snapshot_id" FROM $1 WHERE "is_under_legal_hold" = 'N';
ALTER SNAPSHOT SET my_db_snapshot_set
  MODIFY SNAPSHOT IDENTIFIER '790d1ee4-88b2-451f-9ccc-eacd1e93a134'
  ADD LEGAL HOLD;

USE ROLE my_legal_hold_role; -- use a role that has the APPLY LEGAL HOLD privilege
SHOW SNAPSHOTS IN SNAPSHOT SET my_db_snapshot_set
  ->> SELECT "created_on", "snapshot_id" FROM $1 WHERE "is_under_legal_hold" = 'Y';
ALTER SNAPSHOT SET my_db_snapshot_set
  MODIFY SNAPSHOT IDENTIFIER '790d1ee4-88b2-451f-9ccc-eacd1e93a134'
  REMOVE LEGAL HOLD;
Copy
语言: 中文