Question

What are the differences between EXPLAIN and DESC commands in MySQL ?

Was it helpful?

Solution

  • Explain will give you more information about a query,
  • describe will give you more information about tables or columns.

You can also use EXPLAIN on a table name, in which case it will behave exactly like DESCRIBE.

EXPLAIN SELECT * 
FROM `customer`

id  select_type  table  type  possible_keys  key  key_len  ref  rows  Extra 
1 SIMPLE customer ALL NULL NULL NULL NULL 2 

vs.

DESCRIBE `customer`
Field  Type  Null  Key  Default  Extra 
CustomerID varchar(2) NO      
Cx varchar(3) NO   
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top