CREATE SHARE¶
Creates a new, empty share. Once the share is created, you can include a database and objects from the database (schemas, tables, and views) in the share using the GRANT <privilege> … TO SHARE command. You can then use ALTER SHARE to add one or more accounts to the share.
This command supports the following variants:
- Variant syntax: Creates a share if it doesn’t exist or alters an existing share.
- See also:
DROP SHARE , ALTER SHARE , SHOW SHARES , DESCRIBE SHARE , CREATE OR ALTER <object>
Syntax¶
Variant syntax¶
CREATE OR ALTER SHARE¶
Creates a new share if it doesn’t already exist, or transforms an existing share into the share defined in the statement. A CREATE OR ALTER SHARE statement follows the syntax rules of a CREATE SHARE statement and has the same limitations as an ALTER SHARE statement.
The following modifications are supported when altering a share:
- Adding, updating, or removing a COMMENT.
Required parameters¶
nameSpecifies the identifier for the share; must be unique for the account in which the share is created.
In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (e.g.
"My object"). Identifiers enclosed in double quotes are also case-sensitive.For more details, see Identifier requirements.
Optional parameters¶
COMMENT = 'string_literal'Specifies a comment for the share.
Default: No value
Access control requirements¶
A role used to execute this operation must have the following privileges at a minimum:
| Privilege | Object | Notes |
|---|---|---|
| CREATE SHARE | Account | Only the ACCOUNTADMIN role has this privilege by default. The privilege can be granted to additional roles as needed. |
| OWNERSHIP | Share | Required to execute a Variant syntax statement for an existing share. |
For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.
For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
For more information about access control requirements for Snowflake Secure Data Sharing specifically, see Enable non-ACCOUNTADMIN roles to perform data sharing tasks.
Usage notes¶
-
Regarding metadata:
Attention
Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
- The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
-
CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
CREATE OR ALTER SHARE¶
- All limitations of the ALTER SHARE command apply.
- Adding or removing accounts from the share is not supported. Use ALTER SHARE to add or remove consumer accounts.
- Setting or unsetting a tag is not supported.
- Renaming a share is not supported.
Examples¶
Create an empty share named sales_s:
After you create the share, complete it by running the following commands:
- Run the GRANT <privilege> … TO SHARE command to add a database (and objects in the database) to the share.
- Run the ALTER SHARE command to add accounts to the share.
CREATE OR ALTER SHARE¶
Create a new share or update the comment for an existing share: