How to get all columns' names for all the tables in MySQL?

前端 未结 10 2323
你的背包
你的背包 2020-11-28 01:13

Is there a fast way of getting all column names from all tables in MySQL, without having to list all the tables?

10条回答
  •  爱一瞬间的悲伤
    2020-11-28 01:55

    On the offchance that it's useful to anyone else, this will give you a comma-delimited list of the columns in each table:

    SELECT table_name,GROUP_CONCAT(column_name ORDER BY ordinal_position)
    FROM information_schema.columns
    WHERE table_schema = DATABASE()
    GROUP BY table_name
    ORDER BY table_name
    

    Note : When using tables with a high number of columns and/or with long field names, be aware of the group_concat_max_len limit, which can cause the data to get truncated.

提交回复
热议问题