CREATE SHARE
statementsupportedNative apps, listings & sharingCreates 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: - CREATE OR ALTER SHARE: Creates a share if it doesn’t exist or alters an existing share. - DEFINE SHARE: Declarative definition of a share’s target state inside a DCM project. Provider sharing is enabled by default for most, but not all, accounts. If you encounter errors when attempting to share data with consumers, the feature may not be enabled for your account. To inquire about enabling it, please contact Snowflake Support.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] SHARE [ IF NOT EXISTS ] <name>
[ SECURE_OBJECTS_ONLY = { TRUE | FALSE } ]
[ COMMENT = '<string_literal>' ]
For more information, see CREATE OR ALTER <object>.
CREATE OR ALTER SHARE <name>
[ COMMENT = '<string_literal>' ]
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Specifies 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 (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more details, see Identifier requirements. |
SECURE_OBJECTS_ONLY = { TRUE | FALSE } | optional | Specifies whether the share can have only secure objects granted to it. TRUE allows only secure objects to be granted to the share. FALSE also allows non-secure objects, such as non-secure views, to be granted to the share. For more information, see Share data in non-secured views. If you grant a non-secure object to a share with SECURE_OBJECTS_ONLY = TRUE, Snowflake returns the error Non-secure object can only be granted to shares with "secure_objects_only" property set to false. After you set this parameter to FALSE, you can’t set it to TRUE or unset it. Default: TRUE |
COMMENT = 'string_literal' | optional | Specifies a comment for the share. Default: No value |
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.
- 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 SHARE_RESTRICTIONS isn’t supported. Use ALTER SHARE with ADD | REMOVE ACCOUNTS to set SHARE_RESTRICTIONS.
- Setting or unsetting a tag is not supported.
- Renaming a share is not supported.
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 CREATE OR ALTER SHARE 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.