snow object create

Create an object of a given type.

Syntax

snow object create
  <object_type>
  <object_attributes>
  --json <object_json>
  --connection <connection>
  --account <account>
  --user <user>
  --password <password>
  --authenticator <authenticator>
  --private-key-path <private_key_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>
  --format <format>
  --verbose
  --debug
  --silent
Copy

Arguments

object_type

Type of object. For example table, database, compute-pool.

object_attributes...

Object attributes provided as a list of <key>=<value> pairs, such as name=my_db comment='created with Snowflake CLI'.

Options

--json TEXT

Object definition in JSON format, for example {"name": "my_db", "comment": "created with Snowflake CLI"}.

--connection, -c, --environment TEXT

Name of the connection, as defined in your config.toml. Default: default.

--account, --accountname TEXT

Name assigned to your Snowflake account. Overrides the value specified for the connection.

--user, --username TEXT

Username to connect to Snowflake. Overrides the value specified for the connection.

--password TEXT

Snowflake password. Overrides the value specified for the connection.

--authenticator TEXT

Snowflake authenticator. Overrides the value specified for the connection.

--private-key-path TEXT

Snowflake private key path. Overrides the value specified for the connection.

--database, --dbname TEXT

Database to use. Overrides the value specified for the connection.

--schema, --schemaname TEXT

Database schema to use. Overrides the value specified for the connection.

--role, --rolename TEXT

Role to use. Overrides the value specified for the connection.

--warehouse TEXT

Warehouse to use. Overrides the value specified for the connection.

--temporary-connection, -x

Uses connection defined with command line parameters, instead of one defined in config.

--mfa-passcode TEXT

Token to use for multi-factor authentication (MFA).

--enable-diag

Run python connector diagnostic test.

--diag-log-path TEXT

Diagnostic report path.

--diag-allowlist-path TEXT

Diagnostic report path to optional allowlist.

--format [TABLE|JSON]

Specifies the output format.

--verbose, -v

Displays log entries for log levels info and higher.

--debug

Displays log entries for log levels debug and higher; debug logs contains additional information.

--silent

Turns off intermediate output to console.

--help

Displays 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:

For each object, you must specify the appropriate object details using either the object attributes or the object definitions.

  • Use the object_attributes parameter 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"
    
    Copy
  • Use the --json object_definition option 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
    
    Copy
  • 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 each object type.

Compute pool object attributes

Compute pool 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

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

Image repository object attributes

Image repository attributes

Attribute

Description

name

required, string

Snowflake object identifier.

Schema object attributes

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

Service object attributes

Service 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

Service specification attributes

Attribute

Description

spec_type

required, string

Type of the service specification. Possible values include from_file or from_inline.

spec_text

required, string

(Valid only for spec_type="from_inline")

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 spec_type="from_inline")

Snowflake internal stage where the specification file is stored, such as @tutorial_stage.

name

required, string

(Valid only for spec_type="from_inline")

Path to the service specification file on the stage, such as some-dir/echo_spec.yaml.

Table object attributes

Table 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

mMximum 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

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

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 constraint_type="FOREIGN KEY")

Name of table referenced by foreign key

referenced_column_names

optional, string

(Valid only for constraint_type="FOREIGN KEY")

Names of columns referenced by foreign key

Task attributes

Task attributes

Attribute

Description

name

required, string

Snowflake object identifier.

definition

required, string

String that specifies the identifier, such as name, for the task.

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.

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

Task schedule attributes

Attribute

Description

schedule_type

optional, string

Type of the schedule. Possible values include CRON_TYPE or MINUTES_TYPE.

cron_expr

optional, string

(Valid only for schedule_type="CRON_TYPE")

A cron expression for the task execution, such as “* * * * ? *”.

timezone

optional, string

(Valid only for schedule_type="CRON_TYPE")

Time zone for the schedule, for example "america/los_angeles".

minutes

optional, string

(Valid only for schedule_type="MINUTES_TYPE")

Number of minutes between each task run.

Warehouse attributes

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-attributes parameter:

    snow object create database name=my_db comment='Created with Snowflake CLI'
    
    Copy
  • Create a table object using the option-attributes parameter:

    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
    
    Copy
  • Create a database using the --json object-definition option:

    snow object create database --json '{"name":"my_db", "comment":"Created with Snowflake CLI"}'
    
    Copy
  • Create a table using the --json object-definition option:

    snow object create table --json "$(cat table.json)" --database my_db
    
    Copy

    where table.json contains the following:

    {
      "name": "my_table",
      "columns": [
        {
          "name": "col1",
          "datatype": "number",
          "nullable": false
        }
      ],
      "constraints": [
        {
          "name": "prim_key",
          "column_names": ["col1"],
          "constraint_type": "PRIMARY KEY"
        }
      ]
    }
    
    Copy