snow object create¶
Create an object of a given type. Check documentation for the list of supported objects and parameters.
Syntax¶
snow object create
<object_type>
<object_attributes>
--json <object_json>
--if-not-exists
--replace
--connection <connection>
--host <host>
--port <port>
--account <account>
--user <user>
--password <password>
--authenticator <authenticator>
--workload-identity-provider <workload_identity_provider>
--private-key-file <private_key_file>
--token <token>
--token-file-path <token_file_path>
--database <database>
--schema <schema>
--role <role>
--warehouse <warehouse>
--temporary-connection
--mfa-passcode <mfa_passcode>
--enable-diag
--diag-log-path <diag_log_path>
--diag-allowlist-path <diag_allowlist_path>
--oauth-client-id <oauth_client_id>
--oauth-client-secret <oauth_client_secret>
--oauth-authorization-url <oauth_authorization_url>
--oauth-token-request-url <oauth_token_request_url>
--oauth-redirect-uri <oauth_redirect_uri>
--oauth-scope <oauth_scope>
--oauth-disable-pkce
--oauth-enable-refresh-tokens
--oauth-enable-single-use-refresh-tokens
--client-store-temporary-credential
--format <format>
--verbose
--debug
--silent
--enhanced-exit-codes
Arguments¶
object_typeType of object. For example table, database, compute-pool.
object_attributes...Object attributes provided as a list of key=value pairs, for example name=my_db comment=’created with Snowflake CLI’. Check documentation for the full list of available parameters for every object. .
Options¶
--json TEXTObject definition in JSON format, for example ‘{“name”: “my_db”, “comment”: “created with Snowflake CLI”}’. Check documentation for the full list of available parameters for every object.
--if-not-existsOnly apply this operation if the specified object does not already exist. Default: False.
--replaceReplace this object if it already exists. Default: False.
--connection, -c, --environment TEXTName of the connection, as defined in your
config.tomlfile. Default:default.--host TEXTHost address for the connection. Overrides the value specified for the connection.
--port INTEGERPort for the connection. Overrides the value specified for the connection.
--account, --accountname TEXTName assigned to your Snowflake account. Overrides the value specified for the connection.
--user, --username TEXTUsername to connect to Snowflake. Overrides the value specified for the connection.
--password TEXTSnowflake password. Overrides the value specified for the connection.
--authenticator TEXTSnowflake authenticator. Overrides the value specified for the connection.
--workload-identity-provider TEXTWorkload identity provider (AWS, AZURE, GCP, OIDC). Overrides the value specified for the connection.
--private-key-file, --private-key-path TEXTSnowflake private key file path. Overrides the value specified for the connection.
--token TEXTOAuth token to use when connecting to Snowflake.
--token-file-path TEXTPath to file with an OAuth token to use when connecting to Snowflake.
--database, --dbname TEXTDatabase to use. Overrides the value specified for the connection.
--schema, --schemaname TEXTDatabase schema to use. Overrides the value specified for the connection.
--role, --rolename TEXTRole to use. Overrides the value specified for the connection.
--warehouse TEXTWarehouse to use. Overrides the value specified for the connection.
--temporary-connection, -xUses a connection defined with command line parameters, instead of one defined in config. Default: False.
--mfa-passcode TEXTToken to use for multi-factor authentication (MFA).
--enable-diagWhether to generate a connection diagnostic report. Default: False.
--diag-log-path TEXTPath for the generated report. Defaults to system temporary directory. Default: <system_temporary_directory>.
--diag-allowlist-path TEXTPath to a JSON file that contains allowlist parameters.
--oauth-client-id TEXTValue of client id provided by the Identity Provider for Snowflake integration.
--oauth-client-secret TEXTValue of the client secret provided by the Identity Provider for Snowflake integration.
--oauth-authorization-url TEXTIdentity Provider endpoint supplying the authorization code to the driver.
--oauth-token-request-url TEXTIdentity Provider endpoint supplying the access tokens to the driver.
--oauth-redirect-uri TEXTURI to use for authorization code redirection.
--oauth-scope TEXTScope requested in the Identity Provider authorization request.
--oauth-disable-pkceDisables Proof Key for Code Exchange (PKCE). Default:
False.--oauth-enable-refresh-tokensEnables a silent re-authentication when the actual access token becomes outdated. Default:
False.--oauth-enable-single-use-refresh-tokensWhether to opt-in to single-use refresh token semantics. Default:
False.--client-store-temporary-credentialStore the temporary credential.
--format [TABLE|JSON|JSON_EXT|CSV]Specifies the output format. Default: TABLE.
--verbose, -vDisplays log entries for log levels
infoand higher. Default: False.--debugDisplays log entries for log levels
debugand higher; debug logs contain additional information. Default: False.--silentTurns off intermediate output to console. Default: False.
--enhanced-exit-codesDifferentiate exit error codes based on failure type. Default: False.
--helpDisplays the help text for this command.
Usage notes¶
The snow object create command creates one of the following types Snowflake objects, based on the provided object attributes or definitions:
accountcatalog-integrationcompute-pooldatabasedatabase-roledynamic-tableevent-tableexternal-volumefunctionimage-repositorymanaged-accountnetwork-policynotebooknotification-integrationpipeprocedureroleschemaservicestagestreamtabletaskuser-defined-functionviewwarehouse
For each object, you must specify the appropriate object details using either the object attributes or the object definitions.
Use the
object_attributesparameter specifies the object details as a series of<key>=<value>pairs, such as:snow object create database name=my_db comment="Created with Snowflake CLI"
Use the
--json object_definitionoption to specify the object details as JSON, such as:snow object create table name=my_table columns='[{"name":"col1","datatype":"number", "nullable":false}]' constraints='[{"name":"prim_key", "column_names":["col1"], "constraint_type":"PRIMARY KEY"}]' --database my_db --schema public
See Examples for more examples.
Note
The following object types require a database to be identified in the connection configuration, such as config.toml, or passed to the command using the --database option.
image-repository
schema
service
table
task
The following sections describe the attributes that Snowflake CLI supports for selected object types.
You can find attributes for other types of objects by checking their corresponding SQL CREATE command references, such as CREATE ACCOUNT.
Compute pool object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
min_nodes required, integer |
Minimum number of nodes for the compute pool. |
max_nodes required, integer |
Maximum number of nodes for the compute pool. |
instance_family required, string |
Name of the instance family. For more information about instance families, refer to the SQL CREATE COMPUTE POOL command. |
auto_resume optional, string |
Whether to resume the compute pool automatically when any statement that requires the compute pool is submitted. |
comment optional, string |
Comment describing the compute pool. |
auto_suspend_secs optional, string |
Number of seconds of inactivity after which you want Snowflake to automatically suspend the compute pool. |
Database object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
comment optional, string |
Comment describing the database. |
data_retention_time_in_days optional, integer |
Number of days for which Time Travel actions (CLONE and UNDROP) can be performed on the schema, as well as the default Time Travel retention time for all tables created in the schema. |
default_ddl_collation optional, string |
Default collation specification for all schemas and tables added to the database. You can override this default at the schema and individual table level. |
max_data_extension_time_in_days optional, integer |
Maximum number of days for which Snowflake can extend the data retention period for tables in the database to prevent streams on the tables from becoming stale. |
suspend_task_after_num_failures optional, integer |
Number of consecutive failed task runs after which the current task is suspended automatically. |
user_task_managed_initial_warehouse_size optional, integer |
Size of the compute resources to provision for the first run of the task, before a task history is available for Snowflake to determine an ideal size. Possible values include: XSMALL, SMALL, MEDIUM, LARGE, and XLARGE. |
user_task_timeout_ms optional, integer |
Time limit, in milliseconds, for a single run of the task before it times out. For information, see USER_TASK_TIMEOUT_MS. |
Image repository object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
Schema object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
comment optional, string |
Comment describing the schema. |
data_retention_time_in_days optional, integer |
Number of days for which Time Travel actions (CLONE and UNDROP) can be performed on the schema, as well as the default Time Travel retention time for all tables created in the schema. |
default_ddl_collation optional, string |
Default collation specification for all schemas and tables added to the database. You can override this default at the schema and individual table level. |
max_data_extension_time_in_days optional, integer |
Maximum number of days for which Snowflake can extend the data retention period for tables in the database to prevent streams on the tables from becoming stale. |
suspend_task_after_num_failures optional, integer |
Number of consecutive failed task runs after which the current task is suspended automatically. |
user_task_managed_initial_warehouse_size optional, integer |
Size of the compute resources to provision for the first run of the task, before a task history is available for Snowflake to determine an ideal size. |
user_task_timeout_ms optional, integer |
Time limit, in milliseconds, for a single run of the task before it times out. For information, see USER_TASK_TIMEOUT_MS. |
Service object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
compute_pool required, string |
Name of the compute pool in your account on which to run the service. |
spec required, object |
Service specification. See service specification table for details. |
external_access_integrations optional, string list |
Names of the external access integrations that allow your service to access external sites. |
auto_resume optional, boolean |
Whether to automatically resume a service when a service function or ingress is called. |
min_instances optional, integer |
Minimum number of service instances to run. |
max_instances optional, integer |
Maximum number of service instances to run. |
query_warehouse optional, string |
Warehouse to use if a service container connects to Snowflake to execute a query but does not explicitly specify a warehouse to use. |
comment optional, string |
Comment for the service. |
Service specification attributes
Attribute |
Description |
|---|---|
spec_type required, string |
Type of the service specification. Possible values include |
spec_text required, string |
(Valid only for Service specification. You can use a pair of dollar signs ($$) to delimit the beginning and ending of the specification string. |
stage required, string |
(Valid only for Snowflake internal stage where the specification file is stored, such as |
name required, string |
(Valid only for Path to the service specification file on the stage, such as |
Table object attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. The name must be unique for the schema in which the table is created. |
kind optional, string |
Table type. Possible values include: TABLE for permanent tables, TEMPORARY, and TRANSIENT. |
comment optional, string |
Description of the table. |
cluster_by[] optional, string list |
List of one or more columns or column expressions in the table as the clustering key. |
enable_schema_evolution optional, boolean |
Whether to enable or disable schema evolution for the table. |
change_tracking optional, boolean |
Whether to enable or disable change tracking for the table. |
data_retention_time_in_days optional, integer |
Retention period, in days, for the table so that Time Travel actions SELECT, CLONE, UNDROP can be performed on historical data in the table. |
max_data_extension_time_in_days optional, integer |
Maximum number of days Snowflake can extend the data retention period to prevent streams on the table from becoming stale. |
default_ddl_collation optional, string |
Default collation specification for the columns in the table, including columns added to the table in the future. |
columns required, column list |
List of column definitions. See Column definition attributes. |
constraints optional, constraint list |
List of constraint definitions. See Constrain definition attributes. |
Column definition attributes
Attribute |
Description |
|---|---|
name required, string |
Column name. |
datatype required, string |
Type of data contained in the column. |
nullable optional, boolean |
Whether the column allows NULL values. |
collate optional, string |
Collation to use for column operations such as string comparison. |
default optional, string |
Whether to automatically insert a default value in the column if a value is not explicitly specified with an INSERT or CREATE TABLE AS SELECT statement. |
autoincrement optional, boolean |
Whether to automatically increment and include the number in successive columns. |
autoincrement_start optional, integer |
Staring value for the column. |
autoincrement_increment optional, integer |
Increment for determining the next auto-incremented number. |
comment optional, string |
Column description. |
Constraint definition attributes
Attribute |
Description |
|---|---|
name required, string |
Constraint name. |
column_names required, string list |
Names of columns to apply the constraint. |
constraint_type required, string |
Type of the constraint. Possible values include: UNIQUE, PRIMARY KEY and FOREIGN KEY. |
referenced_table_name required, string |
(Valid only for Name of table referenced by foreign key |
referenced_column_names optional, string |
(Valid only for Names of columns referenced by foreign key |
Task attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
definition required, string |
SQL definition for the task. It can be a single SQL statement, a call to a stored procedure, or procedural logic using Snowflake scripting. |
warehouse optional, string |
Virtual warehouse that provides compute resources for task runs. |
schedule optional, string |
Schedule for periodically running the task. See Task schedule attributes for details. |
comment optional, string |
Comment description for the task. |
predecessors optional, string list |
One or more predecessor tasks for the current task. |
user_task_managed_initial_warehouse_size optional, string |
Size of the compute resources to provision for the first run of the task. |
user_task_timeout_ms optional, string |
Time limit, in milliseconds, on a single run of the task before it times out. For information, see USER_TASK_TIMEOUT_MS. |
suspend_task_after_num_failures optional, integer |
Number of consecutive failed task runs after which the current task is suspended automatically. |
condition optional, string |
Boolean SQL expression condition; multiple conditions joined with AND/OR are supported. |
allow_overlapping_execution optional, boolean |
Whether to allow multiple instances of the DAG to run concurrently. |
Task schedule attributes
Attribute |
Description |
|---|---|
schedule_type optional, string |
Type of the schedule. Possible values include |
cron_expr optional, string |
(Valid only for A cron expression for the task execution, such as |
timezone optional, string |
(Valid only for Time zone for the schedule, for example |
minutes optional, string |
(Valid only for Number of minutes between each task run. |
Warehouse attributes¶
Attribute |
Description |
|---|---|
name required, string |
Snowflake object identifier. |
comment optional, string |
Description of the warehouse. |
warehouse_type optional, string |
Type of warehouse. Possible values include: STANDARD and SNOWPARK-OPTIMIZED. |
warehouse_size optional, string |
Size of warehouse. Possible values include: XSMALL, SMALL, MEDIUM, LARGE, XLARGE, XXLARGE, XXXLARGE, X4LARGE, X5LARGE, and X6LARGE. |
auto_suspend optional, string |
Time, in seconds, before the warehouse automatically suspends itself. |
auto_resume optional, string |
Whether to automatically resume a warehouse when a SQL statement is submitted to it. Possible values include: “true” and “false”. |
max_concurrency_level optional, integer |
Concurrency level for SQL statements executed by a warehouse cluster. |
statement_queued_timeout_in_seconds optional, integer |
Time, in seconds, a SQL statement can be queued on a warehouse before it is canceled by the system. |
statement_timeout_in_seconds optional, integer |
Time, in seconds, after which a running SQL statement is canceled by the system. |
resource_monitor optional, string |
Name of a resource monitor that is explicitly assigned to the warehouse. When a resource monitor is explicitly assigned to a warehouse, the monitor controls the monthly credits used by the warehouse. |
Examples¶
Create a database object using the
option-attributesparameter:snow object create database name=my_db comment='Created with Snowflake CLI'
Create a table object using the
option-attributesparameter:snow object create table name=my_table columns='[{"name":"col1","datatype":"number", "nullable":false}]' constraints='[{"name":"prim_key", "column_names":["col1"], "constraint_type":"PRIMARY KEY"}]' --database my_db --schema public
Create a database using the
--json object-definitionoption:snow object create database --json '{"name":"my_db", "comment":"Created with Snowflake CLI"}'
Create a table using the
--json object-definitionoption:snow object create table --json "$(cat table.json)" --database my_db
where
table.jsoncontains the following:{ "name": "my_table", "columns": [ { "name": "col1", "datatype": "number", "nullable": false } ], "constraints": [ { "name": "prim_key", "column_names": ["col1"], "constraint_type": "PRIMARY KEY" } ] }