Skip to main content

event_tables

Creates, updates, deletes, gets or lists an event_tables resource.

Overview

Nameevent_tables
TypeResource
Idsnowflake.event_table.event_tables

Fields

The following fields are returned by SELECT queries:

A Snowflake event table

NameDatatypeDescription
namestringName of the event table
database_namestringDatabase in which the event table is stored
schema_namestringSchema in which the event table is stored
automatic_clusteringbooleanIf Automatic Clustering is enabled for your account, specifies whether it is explicitly enabled or disabled for the table.
bytesinteger (int64)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_trackingbooleanTrue if change tracking is enabled, allowing streams and CHANGES to be used on the entity.
cluster_byarrayCluster key column(s) or expression
columnsarray
commentstringuser comment associated to an object in the dictionary
created_onstring (date-time)Date and time when the event table was created.
data_retention_time_in_daysintegernumber of days to retain the old version of deleted/updated data
default_ddl_collationstringCollation that is used for all the new columns created by the DDL statements (if not specified)
max_data_extension_time_in_daysintegerMaximum number of days to extend data retention beyond the retention period to prevent a stream becoming stale.
ownerstringRole that owns the event table
owner_role_typestringThe type of role that owns the event table
rowsinteger (int64)Number of rows in the table.
search_optimizationbooleanIf ON, the table has the search optimization service enabled
search_optimization_bytesinteger (int64)Number of additional bytes of storage that the search optimization service consumes for this table
search_optimization_progressinteger (int64)Percentage of the table that has been optimized for search

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_event_tablesselectdatabase_name, schema_name, endpointlike, startsWith, showLimit, fromNameList event tables
fetch_event_tableselectdatabase_name, schema_name, name, endpointFetch an event table
create_event_tableinsertdatabase_name, schema_name, endpointcreateMode, copyGrantsCreate an event table
delete_event_tabledeletedatabase_name, schema_name, name, endpointifExistsDelete an event table
rename_event_tableexecdatabase_name, schema_name, name, targetName, endpointifExistsRename the event table

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringIdentifier (i.e. name) for the database to which the resource belongs. You can use the /api/v2/databases GET request to get a list of available databases.
endpointstringOrganization and Account Name (default: orgid-acctid)
namestringIdentifier (i.e. name) for the resource.
schema_namestringIdentifier (i.e. name) for the schema to which the resource belongs. You can use the /api/v2/databases/{database}/schemas GET request to get a list of available schemas for the specified database.
targetNamestringSpecify the name of the target resource to be renamed to.
copyGrantsbooleanQuery parameter to enable copy grants when creating the object.
createModestringQuery parameter allowing support for different modes of resource creation. Possible values include: - errorIfExists: Throws an error if you try to create a resource that already exists. - orReplace: Automatically replaces the existing resource with the current one. - ifNotExists: Creates a new resource when an alter is requested for a non-existent resource.
fromNamestringQuery parameter to enable fetching rows only following the first row whose object name matches the specified string. Case-sensitive and does not have to be the full name.
ifExistsbooleanQuery parameter that specifies how to handle the request for a resource that does not exist: - true: The endpoint does not throw an error if the resource does not exist. It returns a 200 success response, but does not take any action on the resource. - false: The endpoint throws an error if the resource doesn't exist.
likestringQuery parameter to filter the command output by resource name. Uses case-insensitive pattern matching, with support for SQL wildcard characters.
showLimitintegerQuery parameter to limit the maximum number of rows returned by a command.
startsWithstringQuery parameter to filter the command output based on the string of characters that appear at the beginning of the object name. Uses case-sensitive pattern matching.

SELECT examples

List event tables

SELECT
name,
database_name,
schema_name,
automatic_clustering,
bytes,
change_tracking,
cluster_by,
columns,
comment,
created_on,
data_retention_time_in_days,
default_ddl_collation,
max_data_extension_time_in_days,
owner,
owner_role_type,
rows,
search_optimization,
search_optimization_bytes,
search_optimization_progress
FROM snowflake.event_table.event_tables
WHERE database_name = '{{ database_name }}' -- required
AND schema_name = '{{ schema_name }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND like = '{{ like }}'
AND startsWith = '{{ startsWith }}'
AND showLimit = '{{ showLimit }}'
AND fromName = '{{ fromName }}';

INSERT examples

Create an event table

INSERT INTO snowflake.event_table.event_tables (
data__name,
data__cluster_by,
data__data_retention_time_in_days,
data__max_data_extension_time_in_days,
data__change_tracking,
data__default_ddl_collation,
data__comment,
database_name,
schema_name,
endpoint,
createMode,
copyGrants
)
SELECT
'{{ name }}' --required,
'{{ cluster_by }}',
{{ data_retention_time_in_days }},
{{ max_data_extension_time_in_days }},
{{ change_tracking }},
'{{ default_ddl_collation }}',
'{{ comment }}',
'{{ database_name }}',
'{{ schema_name }}',
'{{ endpoint }}',
'{{ createMode }}',
'{{ copyGrants }}'
;

DELETE examples

Delete an event table

DELETE FROM snowflake.event_table.event_tables
WHERE database_name = '{{ database_name }}' --required
AND schema_name = '{{ schema_name }}' --required
AND name = '{{ name }}' --required
AND endpoint = '{{ endpoint }}' --required
AND ifExists = '{{ ifExists }}';

Lifecycle Methods

Rename the event table

EXEC snowflake.event_table.event_tables.rename_event_table 
@database_name='{{ database_name }}' --required,
@schema_name='{{ schema_name }}' --required,
@name='{{ name }}' --required,
@targetName='{{ targetName }}' --required,
@endpoint='{{ endpoint }}' --required,
@ifExists={{ ifExists }};