Mysql 如何显示架构中所有表的列标题

Mysql 如何显示架构中所有表的列标题,mysql,sql,database,Mysql,Sql,Database,我想列出一个模式中的所有表和列标题,以便在MySQL中以行的形式显示,我似乎无法在网上找到答案,非常感谢您的帮助 e、 g我的模式中有50个表,表1、表2和表3…. 表中的列数也不同 我应该使用什么查询来显示以下内容 | table1 | 01col1 header | 01col2 header | 01col3 header | 01col4 header | | table2 | 02col1 header | 02col2 header | 02col3 header | 02col

我想列出一个模式中的所有表和列标题,以便在MySQL中以行的形式显示,我似乎无法在网上找到答案,非常感谢您的帮助

e、 g我的
模式中有50个表,表1、表2和表3….

表中的列数也不同

我应该使用什么查询来显示以下内容


| table1 | 01col1 header | 01col2 header | 01col3 header | 01col4 header |

| table2 | 02col1 header | 02col2 header | 02col3 header | 02col4 header | 02col5 header |

| table3 | 03col1 header | 03col2 header | 03col3 header |

| ...... |

| table50| 50col1 header | 50col2 header |

谢谢大家!

您可以将information\u schema.columns与条件聚合一起使用

select table_name,
        max(case when ordinal_position = 1 then column_name end) as col1name,
        max(case when ordinal_position = 2 then column_name end) as col2name,
        max(case when ordinal_position = 3 then column_name end) as col3name
from information_schema.`COLUMNS`
group by table_name;
如果所有表中的最大列数都非常大或可能会发生更改,那么您可以修改此代码以构建一个准备好的语句