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

前端 未结 8 1967
天命终不由人
天命终不由人 2021-01-31 08:01

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

Something like this:

describe * from myDB;
8条回答
  •  南笙
    南笙 (楼主)
    2021-01-31 08:32

    Not sure if there is a way to get the results to display in a "table" format as it does when running the command from the mysql prompt, but this should describe all tables formatted vertically.

    mysql -N -uUSER -pPASSWORD DATABASE_NAME --execute="show tables" | while read table; do mysql -uUSER -pPASSWORD DATABASE_NAME --execute="describe $table \G"; done
    

提交回复
热议问题