如何在MySQL中的所有表/视图中获取所有列的计数
如何在给定的MySQL数据库中的所有视图/表中获取所有列的计数?
例如,给定的架构类似于以下架构:
table_1 | table_2 | table_1_col_1 |
---|---|---|
table_2_col_1 | view_1 | view_1_col_1 |
table_1_col_2 |
我得到:
table_name | column_count_count_count |
---|---|
table_1 | 2 |
table_2 table_1 | 1 |
view_1 1 | 1 |
How do I get the count of all the columns in all views/tables in a given mysql database?
For example given a schema similar to:
TABLE_1 | TABLE_2 | VIEW_1 |
---|---|---|
TABLE_1_COL_1 | TABLE_2_COL_1 | VIEW_1_COL_1 |
TABLE_1_COL_2 |
I'd get:
table_name | column_count |
---|---|
TABLE_1 | 2 |
TABLE_2 | 1 |
VIEW_1 | 1 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用内置的 Information_schema 表来检索以下操作:
此外,您可以通过添加到Where子句来过滤;例如,您只能过滤具有前缀 v _ 的表/视图,通过将其添加到Where子句如下:
You can use the built-in information_schema table to retrieve this:
Furthermore you can filter by adding to the where clause; for example you can filter only the tables/views that have the prefix v_ by adding to the where clause as follows: