Skip to main content

Describe

Describing a Table

To view the schema of a table, use the DESCRIBE statement (or its aliases DESC and SHOW) followed by the table name.

Query
CREATE TABLE tbl (i INTEGER PRIMARY KEY, j VARCHAR);
DESCRIBE TABLE tbl;
SHOW TABLE tbl;
Result
 column_name | column_type | null | key  | default | extra-------------+-------------+------+------+---------+------- i           | INTEGER     | NO   | PRI  | NULL    | NULL j           | VARCHAR     | YES  | NULL | NULL    | NULL
 column_name | column_type | null | key  | default | extra-------------+-------------+------+------+---------+------- i           | INTEGER     | NO   | PRI  | NULL    | NULL j           | VARCHAR     | YES  | NULL | NULL    | NULL

Describing a Query

To view the schema of the result of a query, prepend DESCRIBE to a query.

Query
DESCRIBE SELECT * FROM tbl;
Result
 column_name | column_type | null | key  | default | extra-------------+-------------+------+------+---------+------- i           | INTEGER     | NO   | PRI  | NULL    | NULL j           | VARCHAR     | YES  | NULL | NULL    | NULL

Using DESCRIBE in a Subquery

DESCRIBE can be used as a subquery. This allows creating a table from the description, for example:

Query
CREATE TABLE tbl_description AS SELECT * FROM (DESCRIBE TABLE tbl);

Describing Remote Tables

It is possible to describe remote tables over HTTP(S) and S3 using the DESCRIBE TABLE statement. For example:

Query
DESCRIBE TABLE 'https://example.com/data.csv';
Result
 column_name | column_type | null | key  | default | extra-------------+-------------+------+------+---------+------- a           | BIGINT      | YES  | NULL | NULL    | NULL b           | VARCHAR     | YES  | NULL | NULL    | NULL c           | DOUBLE      | YES  | NULL | NULL    | NULL