CLASS_INSTANCES view | Snowflake Documentation (original) (raw)

This Account Usage view displays a row for each instance of a class defined in the account.

Columns

Column Name Data Type Description
ID NUMBER Internal/system-generated identifier for the instance.
NAME VARCHAR Name of the instance.
SCHEMA_ID NUMBER Internal/system-generated identifier for the schema of the instance.
SCHEMA_NAME VARCHAR Name of the schema the instance belongs to.
DATABASE_ID NUMBER Internal/system-generated identifier for the database of the instance.
DATABASE_NAME VARCHAR Name of the database the instance belongs to.
CLASS_ID NUMBER Internal/system-generated identifier for the class the instance is instantiated from.
CLASS_NAME VARCHAR Name of the class the instance is instantiated from.
CLASS_SCHEMA_ID NUMBER Internal/system-generated identifier for the schema of the class the instance is instantiated from.
CLASS_SCHEMA_NAME VARCHAR Name of the schema of the class the instance is instantiated from.
CLASS_DATABASE_ID NUMBER Internal/system-generated identifier for the database of the class the instance is instantiated from.
CLASS_DATABASE_NAME VARCHAR Name of the database of the class the instance is instantiated from.
OWNER_NAME VARCHAR Name of the role that owns the instance.
OWNER_ROLE_TYPE VARCHAR The internal/system-generated identifier of the role that owns the instance of the class.
CREATED TIMESTAMP_LTZ Date and time when the instance was created.
DELETED TIMESTAMP_LTZ Date and time when the instance was deleted.
COMMENT VARCHAR Comment for the instance.

Usage notes

Examples

The following example finds all instances of the ANOMALY_DETECTION class:

SELECT NAME, DATABASE_NAME, SCHEMA_NAME, CLASS_NAME FROM SNOWFLAKE.ACCOUNT_USAGE.CLASS_INSTANCES WHERE CLASS_NAME = 'ANOMALY_DETECTION';

The following example joins this view with TABLES view on the INSTANCE_ID column to find the tables that belong to each instance:

SELECT a.TABLE_NAME, b.NAME AS instance_name, b.CLASS_NAME FROM SNOWFLAKE.ACCOUNT_USAGE.TABLES a JOIN SNOWFLAKE.ACCOUNT_USAGE.CLASS_INSTANCES b ON a.INSTANCE_ID = b.ID WHERE b.DELETED IS NULL;