Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between show column and describe in mysql?

Tags:

mysql

Is there any difference between in MYSQL:-

SHOW COLUMNS from XYZ;

AND

DESC XYZ;

Both seems to give same result

like image 730
Jack Daniel's Avatar asked Mar 24 '14 00:03

Jack Daniel's


2 Answers

The source of information in situations like this is the documentation

EXPLAIN Syntax
DESCRIBE is a shortcut for SHOW COLUMNS.
...
The DESCRIBE statement is provided for compatibility with Oracle.

Both provide means for column name pattern matching

SHOW COLUMNS FROM users LIKE '%name';
DESC users '%name';

Here is SQLFiddle demo

like image 94
peterm Avatar answered Sep 20 '22 00:09

peterm


The short answer is, there is no difference between them in the way you used them.

For other types of usages, they have a bit different syntax and SHOW COLUMNS can be a bit easier to use when you want to specify something like a LIKE 'pattern' or a WHERE expr.

like image 37
Racil Hilan Avatar answered Sep 20 '22 00:09

Racil Hilan