ALTER SNAPSHOT SET

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, DROP SNAPSHOT SET, SHOW SNAPSHOT SETS

语法

ALTER SNAPSHOT SET <name> ADD SNAPSHOT

ALTER SNAPSHOT SET <name> APPLY SNAPSHOT POLICY <policy_name>

ALTER SNAPSHOT SET <name> SUSPEND SNAPSHOT POLICY

ALTER SNAPSHOT SET <name> RESUME SNAPSHOT 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
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

Specifies the snapshot policy to attach to the snapshot set.

重要

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 POLICY

Suspend a snapshot policy in the snapshot set. For more information, see Suspend a snapshot policy on a snapshot set.

RESUME SNAPSHOT POLICY

Resume a suspended snapshot policy in the set. For more information, see Resume a snapshot policy on a snapshot set.

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. For more information, see Delete a snapshot from a snapshot set.

ALTER SNAPSHOT SET name 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 Legal hold. For examples of using this clause, see Add and remove legal holds.

SET COMMENT = 'string_literal'

Associate a comment with the snapshot set.

UNSET COMMENT

Remove the comment from the snapshot set.

访问控制要求

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

权限

描述

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
语言: 中文