在汇总表的时候需要把表数据和属性单独列出来
select * from information_schema.columns where table_name = '表名'
这句话是把所有的属性都列出来了,类似于这样
可根据所需查询属性
1、table_catalog:不管是table | view 这个列的值总是def
2、table_schema :表 | 视图所在的数据库名
3、table_name :表名 | 视图名
4、column_name :列名
5、column_default :列的默认值
6、is_nullable :是否可以取空值
7、data_type :列的数据类型
8、character_maximum_length :列的最大长度(这列只有在数据类型为char | varchar 时才有意义)
9、column_type :列类型这个类型比data_type列所指定的更加详细,如data_type 是int 而column_type 就有可以能是int(11)
10、column_key :列上的索引类型 主键–>PRI | 唯一索引 -->UNI 一般索引 -->MUL
11、column_comment :备注
如下写法可自己查询想要字段并重新命名
select column_name as 列名,column_type as 精度,data_type as 数据类型,is_nullable as 是否为空,column_default as 默认值,column_comment as 备注 from information_schema.columns where table_name = 'user'
结果如下图
参考:/weixin_42686556/article/details/82739595