tables
Creates, updates, deletes, gets or lists a tables
resource.
Overview
Name | tables |
Type | Resource |
Id | snowflake.table.tables |
Fields
Name | Datatype | Description |
---|---|---|
name | string | Specifies the name for the table, must be unique for the schema in which the table is created |
automatic_clustering | boolean | If Automatic Clustering is enabled for your account, specifies whether it is explicitly enabled or disabled for the table. |
budget | string | Name of the budget if the object is monitored by a budget |
bytes | integer | Number of bytes that will be scanned if the entire table is scanned in a query. Note that this number may be different than the number of actual physical bytes stored on-disk for the table |
change_tracking | boolean | Change tracking is enabled or disabled |
cluster_by | array | Specifies one or more columns or column expressions in the table as the clustering key |
columns | array | |
comment | string | Comment for the table |
constraints | array | |
created_on | string | Date and time when the table was created. |
data_retention_time_in_days | integer | Specifies the retention period for the table so that Time Travel actions SELECT, CLONE, UNDROP can be performed on historical data in the table |
database_name | string | Database in which the table is stored |
default_ddl_collation | string | Specifies a default collation specification for the columns in the table, including columns added to the table in the future |
dropped_on | string | Date and time when the table was dropped |
enable_schema_evolution | boolean | Table has schema evolution enabled or disabled |
kind | string | Table type - permanent, transient, or temporary |
max_data_extension_time_in_days | integer | Specifies the retention period for the table so that Time Travel actions SELECT, CLONE, UNDROP can be performed on historical data in the table |
owner | string | Role that owns the table |
owner_role_type | string | The type of role that owns the object. |
rows | integer | Number of rows in the table. Returns NULL for external tables. |
schema_name | string | Schema in which the table is stored |
search_optimization | boolean | If ON, the table has the search optimization service enabled |
search_optimization_bytes | integer | Number of additional bytes of storage that the search optimization service consumes for this table |
search_optimization_progress | integer | Percentage of the table that has been optimized for search. |
table_type | string | Type of the table |
Methods
Name | Accessible by | Required Params | Description |
---|---|---|---|
fetch_table | SELECT | database_name, name, schema_name, endpoint | Fetch a Table using the describe command output. |
list_tables | SELECT | database_name, schema_name, endpoint | Lists the tables under the database and schema. |
create_table | INSERT | database_name, schema_name, data__name, endpoint | Create a table. |
delete_table | DELETE | database_name, name, schema_name, endpoint | Delete a table with the given name. |
create_or_alter_table | REPLACE | database_name, name, schema_name, data__name, endpoint | Create a (or alter an existing) table. Even if the operation is just an alter, the full property set must be provided. |
clone_table | EXEC | database_name, name, schema_name, endpoint | Create a new table by cloning from the specified resource |
create_table_as_select | EXEC | database_name, query, schema_name, endpoint | Create a table as select. |
create_table_as_select_deprecated | EXEC | database_name, name, query, schema_name, data__name, endpoint | Create a table as select. |
create_table_like | EXEC | database_name, name, schema_name, endpoint | Create a new table like the specified resource, but empty |
create_table_like_deprecated | EXEC | database_name, name, newTableName, schema_name, endpoint | Create a new table like the specified resource, but empty |
create_table_using_template | EXEC | database_name, query, schema_name, endpoint | Create a table using template. |
create_table_using_template_deprecated | EXEC | database_name, name, query, schema_name, endpoint | Create a table using template. |
resume_recluster_table | EXEC | database_name, name, schema_name, endpoint | Resume recluster of a table |
resume_recluster_table_deprecated | EXEC | database_name, name, schema_name, endpoint | Resume recluster of a table |
suspend_recluster_table | EXEC | database_name, name, schema_name, endpoint | Suspend recluster of a table |
suspend_recluster_table_deprecated | EXEC | database_name, name, schema_name, endpoint | Suspend recluster of a table |
swap_with_table | EXEC | database_name, name, schema_name, targetName, endpoint | Swap with another table |
swap_with_table_deprecated | EXEC | database_name, name, schema_name, targetTableName, endpoint | Swap with another table |
undrop_table | EXEC | database_name, name, schema_name, endpoint | Undrop specified table |
SELECT
examples
Lists the tables under the database and schema.
SELECT
name,
automatic_clustering,
budget,
bytes,
change_tracking,
cluster_by,
columns,
comment,
constraints,
created_on,
data_retention_time_in_days,
database_name,
default_ddl_collation,
dropped_on,
enable_schema_evolution,
kind,
max_data_extension_time_in_days,
owner,
owner_role_type,
rows,
schema_name,
search_optimization,
search_optimization_bytes,
search_optimization_progress,
table_type
FROM snowflake.table.tables
WHERE database_name = '{{ database_name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';
INSERT
example
Use the following StackQL query and manifest file to create a new tables
resource.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO snowflake.table.tables (
data__name,
data__kind,
data__cluster_by,
data__enable_schema_evolution,
data__change_tracking,
data__data_retention_time_in_days,
data__max_data_extension_time_in_days,
data__default_ddl_collation,
data__columns,
data__constraints,
data__comment,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ kind }}',
'{{ cluster_by }}',
'{{ enable_schema_evolution }}',
'{{ change_tracking }}',
'{{ data_retention_time_in_days }}',
'{{ max_data_extension_time_in_days }}',
'{{ default_ddl_collation }}',
'{{ columns }}',
'{{ constraints }}',
'{{ comment }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
/*+ create */
INSERT INTO snowflake.table.tables (
data__name,
database_name,
schema_name,
endpoint
)
SELECT
'{{ name }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}'
;
- name: tables
props:
- name: database_name
value: string
- name: schema_name
value: string
- name: data__name
value: string
- name: endpoint
value: string
- name: name
value: string
- name: kind
value: string
- name: cluster_by
value: array
- name: enable_schema_evolution
value: boolean
- name: change_tracking
value: boolean
- name: data_retention_time_in_days
value: integer
- name: max_data_extension_time_in_days
value: integer
- name: default_ddl_collation
value: string
- name: columns
value: array
props:
- name: name
value: string
- name: datatype
value: string
- name: nullable
value: boolean
- name: collate
value: string
- name: default
value: string
- name: autoincrement
value: boolean
- name: autoincrement_start
value: integer
- name: autoincrement_increment
value: integer
- name: constraints
value: array
props:
- name: name
value: string
- name: column_names
value: array
- name: constraint_type
value: string
- name: comment
value: string
- name: constraints
value: array
props:
- name: name
value: string
- name: column_names
value: array
- name: constraint_type
value: string
- name: comment
value: string
REPLACE
example
Replaces all fields in the specified tables
resource.
/*+ update */
REPLACE snowflake.table.tables
SET
name = '{{ name }}',
kind = '{{ kind }}',
cluster_by = '{{ cluster_by }}',
enable_schema_evolution = true|false,
change_tracking = true|false,
data_retention_time_in_days = '{{ data_retention_time_in_days }}',
max_data_extension_time_in_days = '{{ max_data_extension_time_in_days }}',
default_ddl_collation = '{{ default_ddl_collation }}',
columns = '{{ columns }}',
constraints = '{{ constraints }}',
comment = '{{ comment }}'
WHERE
database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND data__name = '{{ data__name }}'
AND endpoint = '{{ endpoint }}';
DELETE
example
Deletes the specified tables
resource.
/*+ delete */
DELETE FROM snowflake.table.tables
WHERE database_name = '{{ database_name }}'
AND name = '{{ name }}'
AND schema_name = '{{ schema_name }}'
AND endpoint = '{{ endpoint }}';