Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain Vs Desc anomalies in mysql

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

like image 508
Puru Avatar asked Feb 04 '23 04:02

Puru


1 Answers

  • 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   
like image 184
Konerak Avatar answered Feb 05 '23 18:02

Konerak