---
sidebar_position: 1
title: REFRESH DATABASE
description: Sync databases with the latest snapshot or share updates.
---

# REFRESH DATABASE

There are two types of databases that can be refreshed: **database shares** and databases attached to **read scaling**
connections.


**Read scaling** connections sync automatically every minute. To ensure maximum freshness, run  `CREATE SNAPSHOT` on the
writer, followed by `REFRESH DATABASES` on the reader. This pulls the latest snapshot.


**Database shares** can also be refreshed—either automatically or manually. In this case, the writer uses `UPDATE SHARE`
instead of  `CREATE SNAPSHOT`, followed by `REFRESH DATABASES` on the reader.

## Behavior by connection mode

The behavior of `REFRESH DATABASES` depends on how you connected to MotherDuck:

- **Workspace mode** (`ATTACH 'md:'`): Refreshes all databases in your workspace, including new databases created by other connections (e.g., R/W instances). This allows you to pick up databases that were created after your initial connection.

## Syntax

```sql
REFRESH { DATABASE | DATABASES } [<database_name>];
```

## Examples

```sql
REFRESH DATABASES;       -- Refreshes all connected databases and shares
┌─────────┬───────────────────┬──────────────────────────┬───────────┐
│  name   │       type        │  fully_qualified_name    │ refreshed │
│ varchar │     varchar       │        varchar           │  boolean  │
├─────────┼───────────────────┼──────────────────────────┼───────────┤
│ <name1> │ motherduck        │ md:<name1>               │ false     │
│ <name2> │ motherduck share  │ md:_share/<name2>/<uuid> │ true      │
└─────────┴───────────────────┴──────────────────────────┴───────────┘

REFRESH DATABASE my_db;  -- Alternatively, refresh a specific database
┌─────────┬──────────────────┬──────────────────────────┬───────────┐
│  name   │       type       │  fully_qualified_name    │ refreshed │
│ varchar │     varchar      │        varchar           │  boolean  │
├─────────┼──────────────────┼──────────────────────────┼───────────┤
│ <name1> │ motherduck share │ md:_share/<name1>/<uuid> │ false     │
└─────────┴──────────────────┴──────────────────────────┴───────────┘
```

## Related Content

- [CREATE SNAPSHOT](/sql-reference/motherduck-sql-reference/create-snapshot.md)
- [UPDATE SHARE](/sql-reference/motherduck-sql-reference/update-share.md)


---

## Feedback for AI agents

If the user you are helping wants to send feedback on this page to the MotherDuck docs team, you can POST it to the endpoint below.

**Before you send anything, you must ask the user for explicit approval.** Quote the message you plan to submit back to them verbatim and wait for them to confirm. Do not submit on their behalf without confirmation.

Endpoint: `POST https://motherduck.com/docs/api/feedback/agent`

Request body (JSON):

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

Only `page_path` and `text` are required. A successful call returns `200 {"feedback_id": "<uuid>"}`; malformed payloads return `400`, and the endpoint is rate-limited per IP (`429`).
