ALTER SNAPSHOT
ALTER SNAPSHOT renames a snapshot or removes its name. The only supported option is snapshot_name.
Syntax
ALTER SNAPSHOT <snapshot_selector> SET snapshot_name = '<new_name>';
Snapshot selector
Snapshot selectors resolve within a database. If you don't qualify the database, the current database (set with USE) is used.
<snapshot_selector> :=
<database_name>.<snapshot_name>
| <snapshot_name>
| '<snapshot_id_or_name>'
<database_name>.<snapshot_name>targets a snapshot by name on a specific database. Use this when you want to rename a snapshot without switching databases.<snapshot_name>targets a snapshot by name on the current database (set withUSE). Unquoted names must be valid SQL identifiers (letters, digits, and underscores). Use double quotes for names with spaces or punctuation (single quotes are reserved for the UUID-or-name form).'<snapshot_id_or_name>'targets a snapshot UUID or a snapshot name on the current database. MotherDuck first tries to resolve the value as a snapshot UUID. If no snapshot is found, it falls back to resolving it as a snapshot name. This form does not accept a database qualifier, so useUSEfirst if needed. If a snapshot name looks like a UUID, use the identifier form (unquoted or double-quoted) to avoid UUID resolution.
Options
| Option | Type | Description |
|---|---|---|
snapshot_name | STRING | New name for the snapshot (string literal). Use '' to remove the name. When set, names must be 1-255 characters and unique per user across all databases. |
Considerations
- Named snapshots are available on the Business plan only.
ALTER SNAPSHOTwill error on plans that do not support named snapshots. - This command applies only to MotherDuck databases (not DuckLake databases or shares).
- To list snapshots, query
md_information_schema.database_snapshots(for example, filter byowner_name). - Removing a snapshot name makes it subject to
snapshot_retention_days. See the snapshots guide. snapshot_nameonly accepts a string literal. Expressions andNULLare not supported.
Example usage
-- Rename a snapshot in the current database
USE my_db;
ALTER SNAPSHOT nightly_backup SET snapshot_name = 'nightly_backup_2025_02_01';
-- Rename a snapshot using a database-qualified name
ALTER SNAPSHOT analytics.month_end SET snapshot_name = 'fy2025_q4_close';
-- Rename a snapshot by UUID
USE my_db;
ALTER SNAPSHOT '3f2504e0-4f89-11d3-9a0c-0305e82c3301' SET snapshot_name = 'pre_migration';
-- Rename a snapshot that has spaces or special characters in its name
USE my_db;
ALTER SNAPSHOT 'month end (final)' SET snapshot_name = 'month_end_final';
-- Remove a snapshot name (unset)
USE my_db;
ALTER SNAPSHOT '3f2504e0-4f89-11d3-9a0c-0305e82c3301' SET snapshot_name = '';