Applies to: Databricks SQL Databricks Runtime 10.4 LTS and above Unity Catalog only
The INFORMATION_SCHEMA
is a SQL standard based schema, provided in every catalog created on Unity Catalog.
Within the information schema, you can find a set of views describing the objects known to the schema's catalog that you are privileged to see. The information schema of the SYSTEM
catalog returns information about objects across all catalogs within the metastore. Information schema system tables do not contain metadata about hive_metastore
objects.
The purpose of the information schema is to provide a SQL based, self describing API to the metadata.
Entity relationship diagram of the information schemaâThe following entity relationship (ER) diagram provides an overview of a subset of information schema views and how they relate to each other.
Information schema viewsâ NotesâREPAIR TABLE
may be required for some catalog metadata changes to be reflected in the information schema. For more information, see REPAIR TABLE.STRING
. For query performance, avoid using functions like LOWER()
or UPPER()
on the identifier column. Instead, compare identifiers directly using lowercase values.WHERE table_catalog = 'main' AND table_schema = 'default'
). Refer to the documentation above for a full list of columns that can be used as filters for each Information Schema table.
LIMIT
pushdown is not currently supported, so although it can truncate the results it will not improve performance.SQL
> SELECT table_name, column_name
FROM information_schema.columns
WHERE data_type = 'DOUBLE'
AND table_schema = 'information_schema';
The following are examples of workflows that use the system level information schema tables.
If you want to view all tables that have been created in the last 24 hours, your query could look like the following.
SQL
> SELECT table_name, table_owner, created_by, last_altered, last_altered_by, table_catalog
FROM system.information_schema.tables
WHERE datediff(now(), last_altered) < 1;
If you want to view how many tables you have in each schema, consider the following example.
SQL
> SELECT table_schema, count(table_name)
FROM system.information_schema.tables
WHERE table_schema = 'tpch'
GROUP BY table_schema
ORDER BY 2 DESC
Related articlesâ
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4