Skip to main content

schemas

Creates, updates, deletes, gets or lists a schemas resource.

Overview

Nameschemas
TypeResource
Idsnowflake.schema.schemas

Fields

NameDatatypeDescription
namestringA Snowflake object identifier. If the identifier contains spaces or special characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
budgetstringBudget that defines a monthly spending limit on the compute costs for a Snowflake account or a custom group of Snowflake objects.
commentstringOptional comment in which to store information related to the schema.
created_onstringDate and time the schema was created.
data_retention_time_in_daysintegerNumber of days for which Time Travel actions (CLONE and UNDROP) can be performed on the schema, as well as specifying the default Time Travel retention time for all tables created in the schema
database_namestringDatabase that the schema belongs to
default_ddl_collationstringSpecifies a default collation specification for all tables added to the schema. You an override the default at the schema and individual table levels.
dropped_onstringDate and time the schema was dropped.
is_currentbooleanCurrent schema for the session.
is_defaultbooleanDefault schema for a user.
kindstringSchema type, permanent (default) or transient.
log_levelstringSeverity level of messages that should be ingested and made available in the active event table. Currently, Snowflake supports only TRACE, DEBUG, INFO, WARN, ERROR, FATAL and OFF.
managed_accessbooleanWhether this schema is a managed access schema that centralizes privilege management with the schema owner.
max_data_extension_time_in_daysintegerMaximum number of days for which Snowflake can extend the data retention period for tables in the schema to prevent streams on the tables from becoming stale.
optionsstring
ownerstringName of the role that owns the schema.
owner_role_typestringType of role that owns the object, either ROLE or DATABASE_ROLE.
pipe_execution_pausedbooleanWhether pipe execution is paused.
retention_timeintegerNumber of days that historical data is retained for Time Travel.
serverless_task_max_statement_sizestringSpecifies the maximum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE.
serverless_task_min_statement_sizestringSpecifies the minimum allowed warehouse size for the serverless task. Minimum XSMALL, Maximum XXLARGE.
suspend_task_after_num_failuresintegerSpecifies the number of consecutive failed task runs after which the current task is suspended automatically.
trace_levelstringHow trace events are ingested into the event table. Currently, Snowflake supports only ALWAYS, ON_EVENT, and OFF.
user_task_managed_initial_warehouse_sizestringSize of the compute resources to provision for the first run of the serverless task, before a task history is available for Snowflake to determine an ideal size.
user_task_timeout_msintegerTime limit, in milliseconds, for a single run of the task before it times out.

Methods

NameAccessible byRequired ParamsDescription
fetch_schemaSELECTdatabase_name, name, endpointFetches a schema.
list_schemasSELECTdatabase_name, endpointLists the accessible schemas.
create_schemaINSERTdatabase_name, data__name, endpointCreates a schema, with modifiers as query parameters. You must provide the full schema definition when creating a schema.
delete_schemaDELETEdatabase_name, name, endpointDeletes the specified schema. If you enable the ifExists parameter, the operation succeeds even if the schema does not exist. Otherwise, a 404 failure is returned if the schema does not exist. if the drop is unsuccessful.
create_or_alter_schemaREPLACEdatabase_name, name, data__name, endpointCreates a new, or alters an existing, schema. You must provide the full schema definition even when altering an existing schema.
clone_schemaEXECdatabase_name, name, endpointClones an existing schema, with modifiers as query parameters. You must provide the full schema definition when cloning an existing schema.
undrop_schemaEXECdatabase_name, name, endpointUndrops schema.

SELECT examples

Lists the accessible schemas.

SELECT
name,
budget,
comment,
created_on,
data_retention_time_in_days,
database_name,
default_ddl_collation,
dropped_on,
is_current,
is_default,
kind,
log_level,
managed_access,
max_data_extension_time_in_days,
options,
owner,
owner_role_type,
pipe_execution_paused,
retention_time,
serverless_task_max_statement_size,
serverless_task_min_statement_size,
suspend_task_after_num_failures,
trace_level,
user_task_managed_initial_warehouse_size,
user_task_timeout_ms
FROM snowflake.schema.schemas
WHERE database_name = '{{ database_name }}'
AND endpoint = '{{ endpoint }}';

INSERT example

Use the following StackQL query and manifest file to create a new schemas resource.

/*+ create */
INSERT INTO snowflake.schema.schemas (
data__name,
data__kind,
data__comment,
data__managed_access,
data__data_retention_time_in_days,
data__default_ddl_collation,
data__log_level,
data__pipe_execution_paused,
data__max_data_extension_time_in_days,
data__suspend_task_after_num_failures,
data__trace_level,
data__user_task_managed_initial_warehouse_size,
data__serverless_task_min_statement_size,
data__serverless_task_max_statement_size,
data__user_task_timeout_ms,
database_name,
endpoint
)
SELECT
'{{ name }}',
'{{ kind }}',
'{{ comment }}',
'{{ managed_access }}',
'{{ data_retention_time_in_days }}',
'{{ default_ddl_collation }}',
'{{ log_level }}',
'{{ pipe_execution_paused }}',
'{{ max_data_extension_time_in_days }}',
'{{ suspend_task_after_num_failures }}',
'{{ trace_level }}',
'{{ user_task_managed_initial_warehouse_size }}',
'{{ serverless_task_min_statement_size }}',
'{{ serverless_task_max_statement_size }}',
'{{ user_task_timeout_ms }}',
'{{ database_name }}',
'{{ endpoint }}'
;

REPLACE example

Replaces all fields in the specified schemas resource.

/*+ update */
REPLACE snowflake.schema.schemas
SET
name = '{{ name }}',
kind = '{{ kind }}',
comment = '{{ comment }}',
managed_access = true|false,
data_retention_time_in_days = '{{ data_retention_time_in_days }}',
default_ddl_collation = '{{ default_ddl_collation }}',
log_level = '{{ log_level }}',
pipe_execution_paused = true|false,
max_data_extension_time_in_days = '{{ max_data_extension_time_in_days }}',
suspend_task_after_num_failures = '{{ suspend_task_after_num_failures }}',
trace_level = '{{ trace_level }}',
user_task_managed_initial_warehouse_size = '{{ user_task_managed_initial_warehouse_size }}',
serverless_task_min_statement_size = '{{ serverless_task_min_statement_size }}',
serverless_task_max_statement_size = '{{ serverless_task_max_statement_size }}',
user_task_timeout_ms = '{{ user_task_timeout_ms }}'
WHERE
database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND data__name = '{{ data__name }}'
AND endpoint = '{{ endpoint }}';

DELETE example

Deletes the specified schemas resource.

/*+ delete */
DELETE FROM snowflake.schema.schemas
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND endpoint = '{{ endpoint }}';