从数据库中到处所有中文表名、英文表名、所有列、注释、类型、长度、是否必填等信息,效果如下:
要实现上面的表格可以直接用SQL实现,实现SQL如下:
#查询SQL
select*
FROMinformation_schema.COLUMNS as columns
left join (select TABLE_NAME,table_comment from information_schema.TABLES) as names on columns.table_name = names.TABLE_NAME
WHERE columns.table_schema = 'XXXXX' ;#查询
selectCONCAT(names.TABLE_COMMENT,'(',names.TABLE_NAME,')') as 库表英名,column_comment as 字段备注,column_name as 字段名称,CASE WHEN is_nullable='YES' THEN '是' ELSE '否' end as 是否必填,data_type as 数据类型,character_maximum_length as 数据长度FROMinformation_schema.COLUMNS as columns
left join (select TABLE_NAME,table_comment from information_schema.TABLES) as names on columns.table_name = names.TABLE_NAME
WHERE columns.table_schema = 'XXXXX' #要查询的数据库名称
group by columns.COLUMN_NAME,columns.TABLE_NAME order by columns.TABLE_NAME,columns.column_name;
SQL实现效果: