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.

See also:

DROP SHARE , ALTER SHARE , SHOW SHARES , DESCRIBE SHARE

Syntax¶

CREATE [ OR REPLACE ] SHARE [ IF NOT EXISTS ] <name>
  [ COMMENT = '<string_literal>' ]
Copy

Required Parameters¶

name

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 (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 SQL command 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.

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 Enabling 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.

  • 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.

Examples¶

Create an empty share named sales_s:

CREATE SHARE sales_s;
Copy
+-----------------------------------------+
| status                                  |
|-----------------------------------------|
| Share SALES_S successfully created.     |
+-----------------------------------------+

After you create the share, complete it by running the following commands:

  1. Run the GRANT <privilege> … TO SHARE command to add a database (and objects in the database) to the share.

  2. Run the ALTER SHARE command to add accounts to the share.