DESCRIBE
{DESCRIBE|DESC} table [column]This statement displays information about the columns of a
given table. The DESCRIBE keyword can be
abbreviated to DESC:
DESCRIBE workreq; +--------------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------+------+-----+---------+----------------+ | req_id | int(11) | NO | PRI | NULL | auto_increment | | client_id | int(11) | YES | | NULL | | | client_description | text | YES | MUL | NULL | | | technician_notes | text | YES | | NULL | | +--------------------+---------+------+-----+---------+----------------+
For information on a specific column, supply only the column
name. For information on multiple columns but not all columns, you can
supply a name pattern within quotes and use the wildcard characters
% and _. Quotes around the string aren’t necessary unless the
string contains spaces.
To list the columns in the workreq table that
have names beginning with the characters client,
enter the following:
DESCRIBE workreq 'client%'; +--------------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------+------+-----+---------+-------+ | client_id | int(11) | YES | | NULL | | | client_description | text | YES | MUL | NULL | | +--------------------+---------+------+-----+---------+-------+
Notice that the keyword LIKE is not used. The
fields in the results have the following meanings:
FieldLists the name of each column in the table.
TypeShows the data type of each column.
NullIndicates whether the column in the table may contain a NULL value.
DefaultShows the default value of the column.
KeyIndicates what type of key the column is. If this field is
empty, the column is not indexed. A value of
PRI indicates a PRIMARY
KEY column, UNI indicates a
UNIQUE indexed column, and
MUL means that multiple occurrences, or
duplicate values, are permitted for the column. This is allowed
because the column is only one of multiple columns making up an
index.
ExtraLists any extra information particular to the column.
To understand how the options you use when creating or altering
a table affect the output of DESCRIBE, let’s look
at the schema of the table shown in an earlier example:
SHOW CREATE TABLE workreq \G
*************************** 1. row ***************************
Table: workreq
Create Table: CREATE TABLE 'workreq' (
'req_id' int(11) NOT NULL AUTO_INCREMENT,
'client_id' int(11) DEFAULT NULL,
'client_description' text,
'technician_notes' text,
PRIMARY KEY ('req_id'),
FULLTEXT KEY 'notes_index' ('client_description','technician_notes')
) ENGINE=MyISAM DEFAULT CHARSET=latin1The results of this SHOW CREATE TABLE
statement indicate that client_description is part
of the index called notes_index. The other column
that is part of that index is technician_notes. Notice in the results
of the earlier DESCRIBE statement that only the
first column of the index is marked MUL.