DATABASE_STORAGE_USAGE_HISTORY

functionsupportedDatabases & schemas

docs.snowflake.com ↗

Information SchemaTable functions

This table function can be used to query the average daily storage usage, in bytes, for a single database (or all the databases in your account) within a specified date range. The results include: - All data stored in tables and materialized views in the database(s). - All historical data maintained in Fail-safe for the database(s). Note This function returns storage usage within the last 6 months. Note This function is generally deprecated in favor of the ACCOUNT_USAGE.DATABASE_STORAGE_USAGE_HISTORY view, which provides a more complete data set and supports longer date ranges.

Syntax

supportedpartialnot supportednot scored

DATABASE_STORAGE_USAGE_HISTORY(
      [ DATE_RANGE_START => <constant_expr> ]
      [, DATE_RANGE_END => <constant_expr> ]
      [, DATABASE_NAME => '<string>' ] )

Parameters

NameRequiredDescription
DATE_RANGE_START => constant_expr , DATE_RANGE_END => constant_exprrequiredThe date range, within the last 6 months, for which to retrieve database storage usage: If an end date is not specified, CURRENT_DATE is used as the end of the range. If a start date is not specified, DATE_RANGE_END is used as the start of the range (that is, the default is one day of storage usage). If the range falls outside the last 6 months, an error is returned.
DATABASE_NAME => 'string'requiredThe name of the database to retrieve storage usage history for. Note that the database name must be enclosed in single quotes. Also, if the database name contains any spaces, mixed-case characters, or special characters, the name must be double-quoted within the single quotes (for example, '"My DB"' vs 'mydb'). If no database is specified, data is returned for all the databases in your account.

Usage notes

Output

The function returns the following columns: Column Name | Data Type | Description USAGE_DATE | DATE | Date of this storage usage record. DATABASE_NAME | TEXT | Name of the database. AVERAGE_DATABASE_BYTES | NUMBER | Number of bytes of database storage used, including bytes currently in Time Travel. AVERAGE_FAILSAFE_BYTES | NUMBER | Number of bytes of Fail-safe storage used. If a database has been dropped and its data retention period has passed (that is, the database cannot be recovered using Time Travel), then the database name is reported as DROPPED_id, where id is an internally-generated identifier. This ID can be used to match entries across rows returned by the table function.

See also

Referenced by