Skip to main content

COLUMNS

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 10.4 LTS and above check marked yes Unity Catalog only

INFORMATION_SCHEMA.COLUMNS describes columns of tables and views (relations) in the catalog.

The rows returned are limited to the relations the user is privileged to interact with.

Definition

The COLUMNS relation contains the following columns:

NameData typeNullableStandardDescription
TABLE_CATALOGSTRINGNoYesCatalog that contains the relation.
TABLE_SCHEMASTRINGNoYesSchema that contains the relation.
TABLE_NAMESTRINGNoYesName of the relation the column is part of.
COLUMN_NAMESTRINGNoYesName of the column.
ORDINAL_POSITIONINTEGERNoYesThe position (numbered from 1) of the column within the relation.
COLUMN_DEFAULTSTRINGNoYesThe default value used when the column is not specified in an INSERT, NULL if undefined.
IS_NULLABLESTRINGNoYesYES if column is nullable, NO otherwise.
FULL_DATA_TYPESTRINGNoNoThe data type as specified in the column definition.
DATA_TYPESTRINGNoYesThe simple data type name of the column, or STRUCT, or ARRAY.
CHARACTER_MAXIMUM_LENGTHINTEGERYesYesAlways NULL, reserved for future use.
CHARACTER_OCTET_LENGTHSTRINGYesYesAlways NULL, reserved for future use.
NUMERIC_PRECISIONINTEGERYesYesFor base-2 integral numeric types, FLOAT, and DOUBLE, the number of supported bits. For DECIMAL the number of digits, NULL otherwise.
NUMERIC_PRECISION_RADIXINTEGERYesYesFor DECIMAL 10, for all other numeric types 2, NULL otherwise.
NUMERIC_SCALEINTEGERYesYesFor integral numeric types 0, for DECIMAL the number of digits to the right of the decimal point, NULL otherwise.
DATETIME_PRECISIONINTEGERYesYesFor DATE 0, for TIMESTAMP, and INTERVALSECOND 3, any other INTERVAL 0, NULL otherwise.
INTERVAL_TYPESTRINGYesYesFor INTERVAL the unit portion of the interval, e.g. 'YEAR TO MONTH', NULL otherwise.
INTERVAL_PRECISIONINTERALYesYesAlways NULL, reserved for future use.
MAXIMUM_CARDINALITYINTEGERYesYesAlways NULL, reserved for future use.
IS_IDENTITYSTRINGNoYesAlways ‘NO’, reserved for future use.
IDENTITY_GENERATIONSTRINGYesYesAlways NULL, reserved for future use.
IDENTITY_STARTSTRINGYesYesAlways NULL, reserved for future use.
IDENTITY_INCREMENTSTRINGYesYesAlways NULL, reserved for future use.
IDENTITY_MAXIMUMSTRINGYesYesAlways NULL, reserved for future use.
IDENTITY_MINIMUMSTRINGYesYesAlways NULL, reserved for future use.
IDENTITY_CYCLESTRINGYesYesAlways NULL, reserved for future use.
IS_GENERATEDSTRINGYesYesAlways NULL, reserved for future use.
GENERATION_EXPRESSIONSTRINGYesYesAlways NULL, reserved for future use.
IS_SYSTEM_TIME_PERIOD_STARTSTRINGNoYesAlways NO, reserved for future use.
IS_SYSTEM_TIME_PERIOD_ENDSTRINGNoYesAlways NO, reserved for future use.
SYSTEM_TIME_PERIOD_TIMESTAMP_GENERATIONSTRINGYesYesAlways NULL, reserved for future use.
IS_UPDATABLESTRINGNoYesYES if column is updatable, NO otherwise.
PARTITION_ORDINAL_POSITIONINTEGERYesNoPosition (numbered from 1) of the column in the partition, NULL if not a partitioning column.
COMMENTSTRINGYesNoOptional description of the column.

Constraints

The following constraints apply to the COLUMNS relation:

ClassNameColumn ListDescription
Primary keyCOLUMNS_PKTABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAMEUnique identifier for the column.
Unique keyCOLUMNS_UKTABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION)Unique identifier the column.
Foreign keyCOLUMN_TABLES_FKTABLE_CATALOG, TABLE_SCHEMA, TABLE_NAMEReferences TABLES.

Examples

SQL
-- Show the columns of the CATALOG_PRIVILEGES relation in the main.information_schema schema.
> SELECT ordinal_position, column_name, data_type
FROM main.information_schema.columns
WHERE table_schema = 'information_schema'
AND table_name = 'catalog_privileges'
ORDER BY ordinal_position;
1 grantor STRING
2 grantee STRING
3 catalog_name STRING
4 privilege_type STRING
5 is_grantable STRING