3 - Sharing Your Database
In this section, you'll learn how to share your databases with colleagues and collaborate effectively using MotherDuck's sharing features.
👈 Go back to Part 2: Loading Your Dataset
Creating and Sharing Your Data​
Let's create a table with sample data in your playground database, then share it with others. The docs_playground
database is automatically created when you connect, so you can start experimenting right away!
First, let's populate your playground database with some currency exchange data:
CREATE TABLE docs_playground.currency_rates AS
SELECT
'USD' AS currency_code,
'US Dollar' AS currency_name,
1.0 AS rate_to_usd,
'2024-01-15' AS rate_date
UNION ALL
SELECT
'EUR',
'Euro',
0.85,
'2024-01-15'
UNION ALL
SELECT
'GBP',
'British Pound',
0.75,
'2024-01-15'
UNION ALL
SELECT
'JPY',
'Japanese Yen',
110.0,
'2024-01-15';
Sharing your database​
With your database and sample data in place, you can now share this dataset with others. MotherDuck shares create a point-in-time snapshot of your database that can be accessed by specified users or groups.
When creating a share, the most important parameters control access scope, visibility, and update behavior. By default, shares use ACCESS ORGANIZATION
(only your organization members can access), VISIBILITY DISCOVERABLE
(appears in your organization's shared database list), and UPDATE MANUAL
(creates a static snapshot that doesn't auto-update).
The syntax to create a share visible to everyone in your Organization is CREATE SHARE <share name> from <database name>
.
- SQL
- MotherDuck UI
CREATE SHARE currency_data_share
FROM
docs_playground (ACCESS ORGANIZATION, VISIBILITY DISCOVERABLE);
You can also create shares through the MotherDuck UI by clicking the dropdown menu next to your database and selecting the share option. This will open a window to configure your share settings.
Once created, all members of your organization will be able to view this share in the MotherDuck UI under "Shared with me".
Learn more about sharing in MotherDuck here.
Understanding Share Configuration​
When creating shares, you can control three key aspects: who can access the data, how users discover the share, and when the data updates. Each parameter has specific options that determine the sharing behavior.
ACCESS - Who Can Access the Share​
ACCESS ORGANIZATION
(default): Only members of your organization can access the shareACCESS UNRESTRICTED
: All MotherDuck users across all organizations can access the shareACCESS RESTRICTED
: Only the share owner has initial access; additional users must be granted access viaGRANT
commands
VISIBILITY - How Users Discover the Share​
VISIBILITY DISCOVERABLE
(default): The share appears in your organization's "Shared with me" section for easy discoveryVISIBILITY HIDDEN
: Share can only be accessed via direct URL; not listed in any user interface
- Organization and Restricted shares default to
DISCOVERABLE
- Unrestricted shares can only be
HIDDEN
- Hidden shares can only be used with
ACCESS RESTRICTED
UPDATE - When Share Data Updates​
UPDATE MANUAL
(default): Share content only updates when you runUPDATE SHARE
commandUPDATE AUTOMATIC
: Share automatically reflects database changes within ~5 minutes
Example Share Configurations​
-- Organization share (most common)
CREATE SHARE team_currency_analysis
FROM
docs_playground (
ACCESS ORGANIZATION,
VISIBILITY DISCOVERABLE,
UPDATE MANUAL
);
-- Restricted share for selective access
CREATE SHARE private_analysis
FROM
docs_playground (
ACCESS RESTRICTED,
VISIBILITY HIDDEN,
UPDATE AUTOMATIC
);
Querying Shared Data​
After creating a share, authorized users can access the shared database in two ways: by using the share URL directly or by attaching it as a database alias:
-- Attach a shared database
ATTACH 'md:_share/docs_playground/b556630d-74f1-435c-9459-cfb87d349cb3' AS shared_currency;
-- Query the shared data
SELECT * FROM shared_currency.currency_rates
WHERE rate_to_usd < 1.0
ORDER BY rate_to_usd DESC;
Managing Shares​
You can also manage your existing shares:
SELECT
name,
source_db_name,
access,
visibility
FROM
MD_INFORMATION_SCHEMA.OWNED_SHARES
WHERE
name LIKE '%currency%';
Going further​
Now that you've mastered the basics, here are some next steps to explore:
- Learn about MotherDuck's Dual Execution feature
- Connect to your favorite BI tools: Tableau, Power BI and learn more about read scaling
- Set up data pipelines with dbt
- Look at our supported integrations to integrate with your data stack.