In order to use a database that a colleague shared with you, you can attach it using the DuckDB
ATTACH command. All that you need is a share URL from your colleague.
To detach a database, use the
If the shared database you're reading from is updated (the owner uses the UPDATE SHARE command), you will automatically see raw data related changes (like inserts and updates) within 1 minute. The impact of
ALTER TABLE statements will also be reflected automatically. To see catalog changes (from things like
CREATE TABLE/VIEW/SCHEMA statements) in addition to raw data changes, you'll need to refresh the web page when using the UI. If you're using the CLI or a native client, you'll need to initiate a new connection.
In the following example, we will use the
sample_data database that is automatically attached when you connect to MotherDuck to illustrate how to use the
sample_data database as this one is automatically attached when you connect to MotherDuck.
Let's connect to MotherDuck and list the databases.
You should see the
sample_data which contains sample datasets to query. It's a shared database which is auto attached to any MotherDuck user.
│ database_name │
│ varchar │
│ cloud_ducks │
│ my_db │
│ sample_data │
sample_data database should not be listed anymore.
Let's attach the
sample_data database again.
ATTACH '<share URL>' [AS <database name>];
If you omit the database name, the database will be named the same as the source database.
An attached shared database behaves just like a read-only database in every way.