Categories:

Database, Schema, & Share DDL

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 <name>
  [ COMMENT = '<string_literal>' ]

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 Access Control in Snowflake.

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 the object is replaced, the old object deletion and the new object creation are processed in a single transaction.

Examples

Create an empty share named sales_s:

CREATE SHARE sales_s;

+-----------------------------------------+
| status                                  |
|-----------------------------------------|
| Share SALES_S successfully created.     |
+-----------------------------------------+

After this step, To complete the share, you need to:

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

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

Back to top