DESC

Description

You can use the statement to perform the following operations:

  • View the schema of a table stored in your CelerData cluster, along with the type of the sort key and materialized view of the table.

Syntax

DESC[RIBE] [db_name.]table_name [ALL];

Parameters

ParameterRequiredDescription
db_nameNoThe database name.
table_nameYesThe table name.
ALLNoIf this keyword is specified, you can view the type of the sort key, materialized view, and schema of a table stored in your CelerData cluster. If this keyword is not specified, you only view the table schema.

Output

+-----------+---------------+-------+------+------+-----+---------+-------+
| IndexName | IndexKeysType | Field | Type | Null | Key | Default | Extra |
+-----------+---------------+-------+------+------+-----+---------+-------+

The following table describes the parameters returned by this statement.

ParameterDescription
IndexNameThe table name.
IndexKeysTypeThe type of the sort key of the table.
FieldThe column name.
TypeThe data type of the column.
NullWhether the column values can be NULL.
  • yes: indicates the values can be NULL.
  • no: indicates the values cannot be NULL.
KeyWhether the column is used as the sort key.
  • true: indicates the column is used as the sort key.
  • false: indicates the column is not used as the sort key.
DefaultThe default value for the data type of the column. If the data type does not have a default value, a NULL returned.
ExtraThis field displays the following information about the column:
  • The aggregate function used by the column, such as SUM and MIN.
  • Whether a bloom filter index is created on the column. If so, the value of Extra is BLOOM_FILTER.

Note: For information about how a materialized view is displayed in the output, see Example 2.

Examples

Example 1: View the schema of example_table stored in your CelerData cluster.

DESC example_table;

Or

DESC default_catalog.example_db.example_table;

The output of the preceding statements is as follows.

+-------+---------------+------+-------+---------+-------+
| Field | Type          | Null | Key   | Default | Extra |
+-------+---------------+------+-------+---------+-------+
| k1    | TINYINT       | Yes  | true  | NULL    |       |
| k2    | DECIMAL(10,2) | Yes  | true  | 10.5    |       |
| k3    | CHAR(10)      | Yes  | false | NULL    |       |
| v1    | INT           | Yes  | false | NULL    |       |
+-------+---------------+------+-------+---------+-------+

Example 2: View the schema, type of the sort key, and materialized view of sales_records stored in your CelerData cluster. In the following example, one materialized view store_amt is created based on sales_records.

DESC db1.sales_records ALL;

+---------------+---------------+-----------+--------+------+-------+---------+-------+
| IndexName     | IndexKeysType | Field     | Type   | Null | Key   | Default | Extra |
+---------------+---------------+-----------+--------+------+-------+---------+-------+
| sales_records | DUP_KEYS      | record_id | INT    | Yes  | true  | NULL    |       |
|               |               | seller_id | INT    | Yes  | true  | NULL    |       |
|               |               | store_id  | INT    | Yes  | true  | NULL    |       |
|               |               | sale_date | DATE   | Yes  | false | NULL    | NONE  |
|               |               | sale_amt  | BIGINT | Yes  | false | NULL    | NONE  |
|               |               |           |        |      |       |         |       |
| store_amt     | AGG_KEYS      | store_id  | INT    | Yes  | true  | NULL    |       |
|               |               | sale_amt  | BIGINT | Yes  | false | NULL    | SUM   |
+---------------+---------------+-----------+--------+------+-------+---------+-------+

Example 3: View the schema of hive_table stored in your Hive cluster.

DESC hive_catalog.hive_db.hive_table;

+-------+----------------+------+-------+---------+---------------+ 
| Field | Type           | Null | Key   | Default | Extra         | 
+-------+----------------+------+-------+---------+---------------+ 
| id    | INT            | Yes  | false | NULL    |               | 
| name  | VARCHAR(65533) | Yes  | false | NULL    |               | 
| date  | DATE           | Yes  | false | NULL    | partition key | 
+-------+----------------+------+-------+---------+---------------+

References