How can I describe all tables in the database through one statement?

Is there any statement that can describe all tables in a database?

Something like this:

describe * from myDB;

There is no statement that describe all tables at once. But you may want to do something like this :

SELECT * FROM information_schema.columns WHERE table_schema = 'db_name';

because the other suggestions made very much mess on the screen or just did not do the trick here is a hack for a small db:

describe table_a; describe table_b; describe table_c; 

and so on


I am using linux way. First create a ~/.my.cnf to store the username and password for mysql. Next use the snippet below and run it in the linux terminal.

Generate the tables list and filter the header and awk to generate the column. Then, use the same method to DESC table_name.

for i in $(mysql MYDBNAME -e 'SHOW TABLES' | grep -v "Tables_in" | awk '{print $1}'); do echo "TABLE: $i"; mysql MYDBNAME -e "DESC $i"; done

Hope this helps.


This is a variation of @AlexShaffer's excellent comment, modified to mirror what the Mac terminal's mysql monitor outputs when asked to describe a table.

USE information_schema;

SELECT TABLE_NAME 'Table', COLUMN_NAME 'Field', COLUMN_TYPE 'Type', IS_NULLABLE 'Null',
  COLUMN_KEY 'Key', COLUMN_DEFAULT 'Default', EXTRA 'Extra'
FROM information_schema.columns
WHERE table_schema = 'your_db'
ORDER BY TABLE_NAME;

mysql -B -N -u root -pPASSWORD -h somehost \
-e "SELECT DISTINCT CONCAT('describe ', table_name, ';') AS query FROM information_schema.tables WHERE table_schema='DATABASE_NAME_HERE' " | \
mysql -B -N -u root -pPASSWORD -h somehost DATABASE_NAME_HERE