0


mysql 查询数据库所有表,表字段

工作中,编写xmlsql时需要查询全部字段,可以利用sql快速组装所有的列

1.查询所有的表名

select table_name,table_comment,auto_increment from information_schema.`TABLES`  where table_schema = 'seata';

2.查询某个表的所有字段

select column_name,data_type,column_comment,column_key,extra,character_maximum_length,is_nullable,column_default
from information_schema.columns 
where table_schema = 'seata' and table_name = 'users' ;

3.组装表的所有列

select GROUP_CONCAT("t.",column_name) total
from information_schema.columns 
where table_schema = 'seata' and table_name = 'users' and column_name not in ('id');

标签: mysql 数据库 sql

本文转载自: https://blog.csdn.net/baidu_30829927/article/details/130670858
版权归原作者 hufz00 所有, 如有侵权,请联系我们删除。

“mysql 查询数据库所有表,表字段”的评论:

还没有评论