LEARN HOW TO PREPARE YOUR DATA WAREHOUSE FOR AGENTIC AI WORKLOADSRegister for the webinar

Skip to main content

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

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

Examples

REFRESH DATABASES;       -- Refreshes all connected databases and shares
┌─────────┬───────────────────┬──────────────────────────┬───────────┐
│ name │ type │ fully_qualified_name │ refreshed │
varcharvarcharvarcharboolean
├─────────┼───────────────────┼──────────────────────────┼───────────┤
<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 │
varcharvarcharvarcharboolean
├─────────┼──────────────────┼──────────────────────────┼───────────┤
<name1> │ motherduck share │ md:_share/<name1>/<uuid>false
└─────────┴──────────────────┴──────────────────────────┴───────────┘