CREATE MODEL

Creates a new machine learning model in the current/specified schema or replaces an existing model.

Note

Use the Snowflake Model Registry Python API to create model versions from scratch. Attempting to create models using SQL alone can be challenging without clear understanding of the serialization schema required for the model.

Models are versioned. All models must have at least one version, and one version must be designated as the default. To add a version to a model, use ALTER MODEL … ADD VERSION.

Some properties of a model can be modified (see ALTER MODEL), and multiple versions can be added.

See also:

ALTER MODEL , ALTER MODEL … ADD VERSION , DROP MODEL , SHOW MODELS

Syntax

CREATE [ OR REPLACE ] MODEL [ IF NOT EXISTS ] <name> FROM internalStage
Copy

Where:

internalStage ::=
    @[<namespace>.]<int_stage_name>[/<path>]
  | @[<namespace>.]%<table_name>[/<path>]
  | @~[/<path>]
Copy

For additional internal stage details, see Choosing an internal stage for local files.

Required parameters

name

String that specifies the identifier (i.e. name) for the new model; must be unique for the schema in which the model 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 information, see Identifier requirements.

FROM internalStage

Specifies the internal stage that contains the model’s files. The required layout of these files is not currently documented.

Access control requirements

A role used to execute this SQL command must have the following privileges at a minimum:

Privilege

Object

Notes

CREATE MODEL

Schema

Implied by USAGE on schema

OWNERSHIP

Model

A role must be granted or inherit the OWNERSHIP privilege on the object to create a temporary object that has the same name as the object that already exists in the schema.

Note that operating on any object in a schema also requires the USAGE privilege on the parent database and schema.

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.