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

前端 未结 8 1961
天命终不由人
天命终不由人 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:22

    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;
    

提交回复
热议问题