DESCRIBE
Syntax
DESCRIBE
provides information about the columns in a table. It is a shortcut for SHOW COLUMNS FROM
. These statements also display information for views. (See , "SHOW COLUMNS
Syntax".)
col_name
can be a column name, or a string containing the SQL "%
" and "_
" wildcard characters to obtain output only for the columns with names matching the string. There is no need to enclose the string within quotation marks unless it contains spaces or other special characters.
mysql> DESCRIBE City;
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+----------------+
| Id | int(11) | NO | PRI | NULL | auto_increment |
| Name | char(35) | NO | | | |
| Country | char(3) | NO | UNI | | |
| District | char(20) | YES | MUL | | |
| Population | int(11) | NO | | 0 | |
+------------+----------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
The description for SHOW COLUMNS
provides more information about the output columns (see , "SHOW COLUMNS
Syntax").
If the data types differ from what you expect them to be based on a CREATE TABLE
statement, note that MariaDB sometimes changes data types when you create or alter a table. The conditions under which this occurs are described in , "Silent Column Specification Changes".
The DESCRIBE
statement is provided for compatibility with Oracle.
The SHOW CREATE TABLE
, SHOW TABLE STATUS
, and SHOW INDEX
statements also provide information about tables. See , "SHOW
Syntax".