DESCRIBE

2024-03-05 01:54:26  Updated

Purpose

You can use this statement to query the schema of a table or column.

EXPLAIN, DESCRIBE, and DESC are synonyms.

Syntax

{EXPLAIN | DESCRIBE | DESC} table_name [column_name | wild];

Parameters

Parameter Description
table_name The table name.
column_name The column name of the table.

Examples

  • Query the definition of table t1.

    obclient> DESCRIBE t1;
    +-------+-------------+------+-----+---------+-------+
    | Field | Type        | Null | Key | Default | Extra |
    +-------+-------------+------+-----+---------+-------+
    | c1    | int(11)     | NO   | PRI | NULL    |       |
    | c2    | int(11)     | YES  |     | NULL    |       |
    | c3    | varchar(20) | YES  |     | NULL    |       |
    +-------+-------------+------+-----+---------+-------+
    3 rows in set
    
  • Query the definition of column c1 in table t1.

    obclient> DESCRIBE t1 c1;
    +-------+---------+------+-----+---------+-------+
    | Field | Type    | Null | Key | Default | Extra |
    +-------+---------+------+-----+---------+-------+
    | c1    | int(11) | NO   | PRI | NULL    |       |
    +-------+---------+------+-----+---------+-------+
    1 row in set
    

Contact Us