1. select column_name, column_type,is_nullable,if(akey=1,'PRI',if(akey='Key','主键','')),column_comment from (
    2. select '' table_name,table_name as table_name2,table_name column_name,'' column_type,'' is_nullable,'' akey,TABLE_COMMENT column_comment from information_schema.tables where table_schema = 'bjnp1108'
    3. and table_name not like 'vi_%' and table_name not like 'tb_%' and TABLE_COMMENT != ''
    4. union
    5. select 'Field' table_name,table_name as table_name2,'列名' column_name,'类型' column_type,'可空' is_nullable,'Key' akey,'备注' column_comment from information_schema.tables where table_schema = 'bjnp1108'
    6. and table_name not like 'vi_%' and table_name not like 'tb_%' and TABLE_COMMENT != ''
    7. union
    8. select table_name,table_name as table_name2,column_name, column_type, is_nullable, column_name='id' as akey, column_comment
    9. from information_schema.columns where table_schema = 'bjnp1108'
    10. and table_name not like 'vi_%' and table_name not like 'tb_%'
    11. union
    12. select table_name,table_name as table_name2,'' column_name,'' column_type,'' is_nullable,'' akey,'' from information_schema.tables where table_schema = 'bjnp1108'
    13. and table_name not like 'vi_%' and table_name not like 'tb_%' and TABLE_COMMENT != ''
    14. ) t order by table_name2;

    用datagrip执行, 然后复制粘贴或execute to file