---
sidebar_position: 1
title: ALTER DATABASE
description: Update storage-related settings on a MotherDuck database.
---

The `ALTER DATABASE` statement updates storage-related settings for an existing MotherDuck database.

## Syntax

```sql
ALTER DATABASE <database_name> SET <option> = <value>;
```

## Options

### Native storage databases

These options apply to standard and transient databases backed by MotherDuck native storage.

| Name | Data type | Description |
|------|-----------|-------------|
| `SNAPSHOT_RETENTION_DAYS` | INTEGER | Number of days to retain automatic and unnamed snapshots. Must be a non-negative integer within your [plan limits](#plan-limits-for-native-storage). `0` disables historical snapshots. Named snapshots are retained until unnamed. |

### DuckLake databases

These options apply to [DuckLake](/concepts/ducklake) databases (fully managed and BYOB).

| Name | Data type | Description |
|------|-----------|-------------|
| `AUTO_MAINTENANCE` | BOOLEAN | Enables or disables [auto maintenance](/concepts/ducklake#auto-maintenance) (file optimization and snapshot lifecycle management). Fully managed DuckLake databases have this enabled by default; BYOB databases have it disabled by default. |
| `SNAPSHOT_RETENTION_DAYS` | INTEGER or NULL | Number of days to retain DuckLake snapshots. Defaults to `NULL` (infinite retention). Set a positive integer to enable automatic snapshot expiration. Requires `AUTO_MAINTENANCE` to be enabled. |

## Notes

Use [`ALTER DATABASE SET SNAPSHOT`](/sql-reference/motherduck-sql-reference/alter-database-snapshot) to restore a native storage database to a snapshot.

Refer to the [snapshots guide](/concepts/snapshots) for snapshot behavior and to [Storage lifecycle](/concepts/storage-lifecycle#standard-databases) for plan limits on retention.

## Plan limits for native storage

For standard and transient databases, `SNAPSHOT_RETENTION_DAYS` is limited by plan:

- Business: 0-90 days
- Lite (paid): 1 day (min/max)
- Lite (free): 0 days (min/max)

## Examples

### Native storage

```sql
ALTER DATABASE my_db SET SNAPSHOT_RETENTION_DAYS = 7;
```

### DuckLake

Enable auto maintenance for a BYOB DuckLake database:

```sql
ALTER DATABASE my_ducklake SET AUTO_MAINTENANCE = TRUE;
```

Set a snapshot retention period for a DuckLake database:

```sql
ALTER DATABASE my_ducklake SET SNAPSHOT_RETENTION_DAYS = 7;
```

Revert to infinite snapshot retention:

```sql
ALTER DATABASE my_ducklake SET SNAPSHOT_RETENTION_DAYS = NULL;
```

Disable auto maintenance:

```sql
ALTER DATABASE my_ducklake SET AUTO_MAINTENANCE = FALSE;
```


---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/alter-database/",
  "page_title": "ALTER DATABASE",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
