The System table system.columns contains information about all Columns, including each Column's Type, Location, key associations, compression State, and other Metadata. It can be used to view table structure details and for Analysis of Column storage characteristics.
| | | | \
| Name | Data type | Description | |
|---|---|---|---|
| \ | |||
| database | String | The name of the Database to which the Column belongs. | |
| \ | |||
| table | String | The name of the table to which the Column belongs. | |
| \ | |||
| name | String | The name of the Column. | |
| \ | |||
| type | String | The data type of the Column. | |
| \ | |||
| position | UInt64 | The Column's position in the table, starting from 1. | |
| \ | |||
| default_kind | String | The expression type of the Column's default value. Possible values are DEFAULT, MATERIALIZED, and ALIAS. If undefined, it is an empty string. | |
| \ | |||
| default_expression | String | The specific expression for the Column's default value. If undefined, it is an empty string. | |
| \ | |||
| data_compressed_bytes | UInt64 | The size of the Column's compressed data, in bytes. | |
| \ | |||
| data_uncompressed_bytes | UInt64 | The size of the Column's uncompressed data, in bytes. | |
| \ | |||
| marks_bytes | UInt64 | The size of the Column's mark data, in bytes. | |
| \ | |||
| comment | String | The comment text for the Column. If not defined, it is an empty string. | |
| \ | |||
| is_in_partition_key | UInt8 | Indicates whether the Column is included in the table's partition key expression: | \ |
| \ | |||
| * 1 = Yes (participates in partition logic); | \ | ||
| * 0 = No. | |||
| \ | |||
| is_in_sorting_key | UInt8 | Indicates whether the Column is included in the table's sorting key expression: | \ |
| \ | |||
| * 1 = Yes (participates in data sorting); | \ | ||
| * 0 = No. | |||
| \ | |||
| is_in_primary_key | UInt8 | Indicates whether the Column is included in the table's primary key expression: | \ |
| \ | |||
| * 1 = Yes (used to uniquely identify data rows); | \ | ||
| * 0 = No. | |||
| \ | |||
| is_in_sampling_key | UInt8 | Indicates whether the Column is included in the table's sampling key expression: | \ |
| \ | |||
| * 1 = Yes (participates in data sampling logic); | \ | ||
| * 0 = No. | |||
| \ | |||
| compression_codec | String | The name of the compression codec used by the Column. | |
| \ | |||
| character_octet_length | Nullable(UInt64) | The maximum length of binary data, character data, text data, or images, in bytes. In ByteHouse, this is only valid for the FixedString data type; other types return NULL. | |
| \ | |||
| numeric_precision | Nullable(UInt64) | The precision of approximate numeric data, exact numeric data, integer data, or currency data. In ByteHouse, it is the bit width of integer types, and the decimal precision of Decimal types; other types return NULL. | |
| \ | |||
| numeric_precision_radix | Nullable(UInt64) | The radix of the number system, indicating the precision of approximate numeric data, exact numeric data, integer data, or currency data. In ByteHouse, integer types use 2, Decimal types use 10; other types return NULL. | |
| \ | |||
| numeric_scale | Nullable(UInt64) | The scale of approximate numeric data, exact numeric data, integer data, or currency data. In ByteHouse, only the Decimal type is meaningful; other types return NULL values. | |
| \ | |||
| datetime_precision | Nullable(UInt64) | The decimal precision of the DateTime64 data type. Other data types return NULL values. |
Query column information in the sales_db.order_details table, and only retrieve key fields:
SELECT name AS column_name, type AS column_type, is_in_primary_key, is_in_partition_key, default_kind FROM system.columns WHERE database = 'sales_db' AND table = 'order_details' ORDER BY position;
Example of query results: