Skip to main content

DESCRIBE TABLE

Returns information about table columns.

Syntax

DESC|DESCRIBE TABLE [db.]table [INTO OUTFILE filename] [FORMAT format]

The DESCRIBE statement returns a row for each table column with the following String values:

  • name β€” A column name.
  • type β€” A column type.
  • default_type β€” A clause that is used in the column default expression: DEFAULT, MATERIALIZED or ALIAS. If there is no default expression, then empty string is returned.
  • default_expression β€” An expression specified after the DEFAULT clause.
  • comment β€” A column comment.
  • codec_expression β€” A codec that is applied to the column.
  • ttl_expression β€” A TTL expression.
  • is_subcolumn β€” A flag that equals 1 for internal subcolumns. It is included into the result only if subcolumn description is enabled by the describe_include_subcolumns setting.

All columns in Nested data structures are described separately. The name of each column is prefixed with a parent column name and a dot.

To show internal subcolumns of other data types, use the describe_include_subcolumns setting.

Example

Query:

CREATE TABLE describe_example (
id UInt64, text String DEFAULT 'unknown' CODEC(ZSTD),
user Tuple (name String, age UInt8)
) ENGINE = MergeTree() ORDER BY id;

DESCRIBE TABLE describe_example;
DESCRIBE TABLE describe_example SETTINGS describe_include_subcolumns=1;

Result:

β”Œβ”€name─┬─type──────────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
β”‚ id β”‚ UInt64 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ text β”‚ String β”‚ DEFAULT β”‚ 'unknown' β”‚ β”‚ ZSTD(1) β”‚ β”‚
β”‚ user β”‚ Tuple(name String, age UInt8) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The second query additionally shows subcolumns:

β”Œβ”€name──────┬─type──────────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┬─is_subcolumn─┐
β”‚ id β”‚ UInt64 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ 0 β”‚
β”‚ text β”‚ String β”‚ DEFAULT β”‚ 'unknown' β”‚ β”‚ ZSTD(1) β”‚ β”‚ 0 β”‚
β”‚ user β”‚ Tuple(name String, age UInt8) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ 0 β”‚
β”‚ user.name β”‚ String β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ 1 β”‚
β”‚ user.age β”‚ UInt8 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ 1 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

See Also