Skip to main content

DESCRIBE

Description

This statement is used to display the schema information of the specified table.

Syntax

DESC[RIBE] [<ctl_name>.][<db_name>.]<table_name> [ALL];

Required Parameters

1.<table_name>

Specifies the identifier (i.e., name) of the table, which must be unique within its database.

The identifier must start with a letter character (or any language character if Unicode name support is enabled), and cannot contain spaces or special characters, unless the entire identifier string is enclosed in backticks (e.g., My Object).

The identifier cannot use reserved keywords.

For more details, please refer to identifier requirements and reserved keywords.

Optional Parameters

1.<ctl_name>.<db_name>

Specifies the identifier (i.e., name) of the data catalog and database.

The identifier must start with a letter character (or any language character if Unicode name support is enabled), and cannot contain spaces or special characters, unless the entire identifier string is enclosed in backticks (e.g., My Database).

The identifier cannot use reserved keywords.

For more details, please refer to identifier requirements and reserved keywords.

2.ALL

Only valid for internal tables. Returns all Index information of internal tables.

Return Value

When ALL is not specified, the return value is as follows:

ColumnDescription
FieldColumn name
TypeData type
NullWhether NULL values are allowed
KeyWhether it's a key column
DefaultDefault value
ExtraDisplays some additional information

In version 3.0.7, a new session variable show_column_comment_in_describe was added. When set to true, an additional Comment column will be added to display column comment information.

When ALL is specified, for internal tables, the return value is as follows:

ColumnDescription
IndexNameTable name
IndexKeysTypeTable model
FieldColumn name
TypeData type
NullWhether NULL values are allowed
KeyWhether it's a key column
DefaultDefault value
ExtraDisplays some additional information
VisibleWhether it's visible
DefineExprDefinition expression
WhereClauseFilter condition related definitions

Permission Control

Users executing this SQL command must have at least the following permissions:

Permission (Privilege)ObjectNotes
SELECT_PRIVTableWhen executing DESC, you need to have SELECT_PRIV permission on the queried table

Examples

  1. Display Base Table Schema
DESC test_table;
+---------+-------------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-------+---------+-------+
| user_id | bigint | No | true | NULL | |
| name | varchar(20) | Yes | false | NULL | NONE |
| age | int | Yes | false | NULL | NONE |
+---------+-------------+------+-------+---------+-------+