TABLES view

This Information Schema view displays a row for each table and view in the specified (or current) database, including the views in the INFORMATION_SCHEMA schema itself.

See also:

COLUMNS view , VIEWS view , TABLES view (Account Usage)

Columns

Column NameData TypeDescription
TABLE_CATALOGVARCHARDatabase that the table belongs to.
TABLE_SCHEMAVARCHARSchema that the table belongs to.
TABLE_NAMEVARCHARName of the table.
TABLE_OWNERVARCHARName of the role that owns the table.
TABLE_TYPEVARCHARIndicates the table type. Valid values are BASE TABLE, TEMPORARY TABLE, EXTERNAL TABLE, EVENT TABLE, VIEW, or MATERIALIZED VIEW.
IS_TRANSIENTVARCHARIndicates whether this is a transient table.
CLUSTERING_KEYVARCHARClustering key for the table.
ROW_COUNTNUMBERNumber of rows in the table.
BYTESNUMBERNumber of bytes accessed by a scan of the table.
RETENTION_TIMENUMBERNumber of days that historical data is retained for Time Travel.
SELF_REFERENCING_COLUMN_NAMEVARCHARNot applicable for Snowflake.
REFERENCE_GENERATIONVARCHARNot applicable for Snowflake.
USER_DEFINED_TYPE_CATALOGVARCHARNot applicable for Snowflake.
USER_DEFINED_TYPE_SCHEMAVARCHARNot applicable for Snowflake.
USER_DEFINED_TYPE_NAMEVARCHARNot applicable for Snowflake.
IS_INSERTABLE_INTOVARCHARNot applicable for Snowflake.
IS_TYPEDVARCHARNot applicable for Snowflake.
COMMIT_ACTIONVARCHARNot applicable for Snowflake.
CREATEDTIMESTAMP_LTZCreation time of the table.
LAST_ALTEREDTIMESTAMP_LTZDate and time the object was last altered by a DML, DDL, or background metadata operation. See Usage Notes.
LAST_DDLTIMESTAMP_LTZ

Timestamp of the last DDL operation performed on the table or view.

All supported table/view DDL operations update this field:

  • { CREATE | ALTER | DROP | UNDROP } TABLE
  • { CREATE | ALTER | DROP } VIEW

All ALTER TABLE operations update this field, including setting or unsetting a table parameter (for example, COMMENT, DATA_RETENTION_TIME, etc.) and changes to table columns (ADD / MODIFY / RENAME / DROP).

For more information, see the Usage Notes.

LAST_DDL_BYVARCHAR

The current username for the user who executed the last DDL operation. If the user has been dropped, shows DROPPED_USER(<id>).

For dropped users, you can join the <id> with the USER_ID column in the USERS view of the ACCOUNT_USAGE or ORGANIZATION_USAGE schema.

AUTO_CLUSTERING_ONBOOLEANIndicates whether automatic clustering is enabled for the table.
COMMENTVARCHARComment for this table.
IS_TEMPORARYVARCHARIndicates whether this is a temporary table. Valid values are YES and NO.
IS_ICEBERGVARCHARIndicates whether the table is an Iceberg table. Valid values are YES or NO.
IS_DYNAMICVARCHARIndicates whether the table is a dynamic table. Valid values are YES or NO.
IS_IMMUTABLEVARCHARIndicates whether the table was created with the READ ONLY property. Valid values are YES or NO.
IS_HYBRIDVARCHARIndicates whether the table is a hybrid table. Valid values are YES or NO.

Usage notes

  • The view only displays objects for which the current role for the session has been granted access privileges. The view does not honor the MANAGE GRANTS privilege and consequently may show less information compared to a SHOW command when both are executed with a role that was granted the MANAGE GRANTS privilege.

    This behavior also applies to other account-level privileges and Information Schema views for which there is a corresponding SHOW command.

  • Querying the sum(bytes) for a table does not represent the total storage usage, because the amount does not include Time Travel and Fail-safe usage.

  • The view does not include tables that have been dropped. To view dropped tables, use SHOW TABLES instead.

  • To view only tables in your queries, filter using a WHERE clause, e.g.: ... WHERE table_schema != 'INFORMATION_SCHEMA'

  • Using the value in the LAST_ALTERED column for Time Travel is _not_ recommended and can return unexpected results for the following reaons:

    • Time Travel can only be used to query historical data modified by a DML operation.
    • The LAST_ALTERED column inludes both DML and DDL operations (see the next usage note).
    • For DML operations, the value in the LAST_ALTERED column is the timestamp at the beginning of the statement execution rather than the time of the commit of the transaction containing this statement.
  • The LAST_ALTERED column is updated when the following operations are performed on an object:

    • DDL operations.
    • DML operations (for tables only). This column is updated even when no rows are affected by the DML statement.
    • Background maintenance operations on metadata performed by Snowflake.

    For views and tables, use the LAST_DDL column for the last modification time for an object.

  • The value in the LAST_DDL column is updated as follows:

    • When a table or view is created, the LAST_DDL timestamp is the same as the CREATED timestamp.
    • When a table or view is dropped, the LAST_DDL timestamp is the same as the DELETED timestamp.
    • Last DDL data is not available for operations that occurred before the columns were added. The new DDL fields contain null until a DDL operation is executed.
    • For replicated databases, the LAST_DDL and LAST_DDL_BY fields are only updated for objects in the primary database. After failover, the LAST_DDL and LAST_DDL_BY fields are updated for DDL operations for the tables and views in the newly promoted primary database. These fields will remain unchanged for objects in the now secondary database.
    • For objects in secondary databases that are newly created during a refresh operation, these fields are null.
  • The LAST_ALTERED column does not necessarily indicate the last refreshed time for external tables. To retrieve the last refreshed time for an auto-refreshed external table, you can use the SYSTEM$EXTERNAL_TABLE_PIPE_STATUS function, which returns information such as the timestamp of the last file Snowflake has registered.

Examples

Retrieve the size (in bytes) of all tables in all schemas in the mydatabase database:

SELECT table_schema, SUM(bytes)
  FROM mydatabase.INFORMATION_SCHEMA.TABLES
  GROUP BY TABLE_SCHEMA;