CREATE SHARE
The CREATE SHARE
statement creates a new a share from a database. This command is used to share databases with other users. Learn more about sharing in MotherDuck.
Syntax
CREATE SHARE [<share name>] [FROM <database name>]
([ACCESS ORGANIZATION | UNRESTRICTED] , [VISIBILITY DISCOVERABLE | HIDDEN]);
This statement returns a share URL of the form md:_share/<source_database_name>/<share_token>
.
- If the share is Hidden, you must pass this URL to the data consumer, who will need to
ATTACH
the share. - If the share is Discoverable, passing the URL to the data consumer is optional.
ACCESS Clause
You can configure scope of access of the share:
ACCESS ORGANIZATION
(default) - only members of your Organization can access the share.ACCESS UNRESTRICTED
- all MotherDuck users in all Organizations can access the share.
If omitted, defaults to ACCESS ORGANIZATION
.
VISIBILITY Clause
For Organization scoped shares only, you may choose to make them Discoverable:
VISIBILITY DISCOVERABLE
(default) - all members of your Organization will be able to list/find the share in the UI or SQL.VISIBILITY HIDDEN
- the share can only be accessed directly by the share URL, and is not listed.
If omitted, Organization-scoped shares default to VISIBILITY DISCOVERABLE
. Unrestricted shares can only be Hidden.
Shorthand Convention
- If the database name is omitted, a share will be created from the current/active database.
- If the share name is omitted, the share will be named after the source database.
- If both database and share names are omitted, the share will be named and created after the current/active database.
Example Usage
USE mydb;
CREATE SHARE; # creates an Organization-scoped, Discoverable share named `mydb`
CREATE SHARE FROM db2; # creates an Organization-scoped, Discoverable share named 'db2'
CREATE SHARE birds FROM birds (ACCESS ORGANIZATION, VISIBILITY HIDDEN);
Users of DuckDB version 0.9.2 do not have access to options ACCESS
and VISIBILITY
. Starting with June 6, users on version 0.9.2 can only create Organization-scoped, Discoverable shares.
All shares created prior to June 6 remain Unrestricted and Hidden. To make them Organization-scoped and Discoverable, you can alter them in the UI or delete and create new shares.