Sharing data with specific users
MotherDuck enables you to securely share data with specific users. Common scenarios include:
- Building data applications, in which each tenant should only have access to their own data.
- Sharing sensitive data within your Organization.
- Sharing data outside of your Organization.
Sharing data with others is easy:
- Data provider creates a Hidden share.
- Data provider gets back the share URL and passes this URL to the data consumer.
- Data consumer attaches the share.
- Data provider periodically updates the share to push new data to data consumers.
1. Creating hidden shares
To share a database, first create a Hidden share. No actual data is copied and no additional costs are incurred in this process.
- UI
- SQL
Click on the "trident" next to the database you'd like to share. Select "share".
- Optionally name the share.
- Under Access choose "Anyone in my Organization" if you'd like to limit access to only members of your Organization.
If you choose "Anyone with the share link", MotherDuck users outside of your Organization will have access to this share as well.
- Create the share.
- Copy the resulting ATTACH command to your clipboard and send it to your data consumers.
use birds;
CREATE SHARE birds FROM birds
(ACCESS ORGANIZATION , VISIBILITY HIDDEN); -- This query creates a Hidden share only accessible by members of your organization
> md:_share/birds/e9ads7-dfr32-41b4-a230-bsadgfdg32tfa
Save the returned share URL and pass it to data consumers.
2. Consuming shares
The data consumer in your Organization can use SQL to attach the share and start querying it!
- SQL
Run the ATTACH
command to attach the share as a queryable database. This is a zero-cost metadata-only operation.
ATTACH md:_share/birds/e9ads7-dfr32-41b4-a230-bsadgfdg32tfa; -- Creates a zero-copy clone database called birds
Learn more about ATTACH SHARE.
3. Updating shared data
If the database being shared has changed, in order for the changes to propagate to the data consumer, the data provider needs to update the share.
UPDATE SHARE birds;
Learn more about UPDATE SHARE.
We are working on auto-updating shares.