DESCRIBE and EXPLAIN
DESCRIBE lists the columns of a table; EXPLAIN gives a simple plan table. What each returns here and what is refused.
Syntax#
{ DESCRIBE | DESC } [db_name.]tbl_name
{ DESCRIBE | DESC | EXPLAIN } [FORMAT = TRADITIONAL] explainable_statement
explainable_statement:
SELECT ... | ( SELECT ... ) | WITH ... | INSERT ... | UPDATE ... | DELETE ...DESCRIBE tbl_name is the same as SHOW COLUMNS FROM tbl_name. EXPLAIN tbl_name (a table name instead of a statement) is also read as DESCRIBE.
Arguments#
| Name | Meaning | Default |
|---|---|---|
FORMAT = TRADITIONAL | The only plan format. | TRADITIONAL |
Remarks#
- DESCRIBE returns
Field,Type,Null,Key,Default,Extra.Extrashowsauto_increment,VIRTUAL GENERATED,STORED GENERATED,INVISIBLE. Views, sequences (MariaDB) and temporary tables can be described. Acolumn_nameor pattern after the table is not in the grammar (useSHOW COLUMNS ... LIKE). - EXPLAIN answers MySQL's plan table (
id,select_type,table,partitions,type,possible_keys,key,key_len,ref,rows,filtered,Extra) with one row per table. The values are what this front-end can state truthfully, not estimates:typeisALL,rowsis 1,filteredis 100.00. There is no optimizer to report. ForINSERT,UPDATEandDELETEtheselect_typeisINSERT,UPDATEorDELETE. - Privileges: some privilege on the table (
SELECTis named in the denial) forDESCRIBE; the privileges of the statement forEXPLAIN.
Not supported yet#
EXPLAIN ANALYZE, andEXPLAIN FORMATother thanTRADITIONAL(JSON,TREE): error 1235.EXPLAINof a statement other thanSELECT,UNION,INSERT,UPDATE,DELETE(includingWITHforms at run time): error 1235.EXPLAIN FOR CONNECTION n,EXPLAINwith a column name.- MariaDB
ANALYZE SELECT ...andANALYZE FORMAT=JSON(error 1235).
Examples#
DESCRIBE t;
DESC t;
EXPLAIN SELECT * FROM t WHERE id = 1;
EXPLAIN FORMAT = TRADITIONAL DELETE FROM t WHERE id = 1;