【数据库】Mysql表字段转Java实体(sql语句)

一、Mysql表字段转Java实体(sql语句)

SELECT
    concat( '\n/**\n', ' * ', v.column_comment, '\n', ' */\n', 'public ', v.dataType, ' ', v.column_name, ';' ) resultData
FROM
    (
    SELECT
        CASE
            WHEN ( data_type = 'varchar'
            OR data_type = 'char'
            OR data_type = 'text'
            OR data_type = 'blob' ) THEN 'String'
            WHEN data_type = 'int' THEN 'int'
            WHEN data_type = 'bigint' THEN 'Long'
            WHEN data_type = 'double' THEN 'double'
        END AS dataType,
        column_name,
        column_comment
    FROM
        information_schema. COLUMNS
    WHERE
        table_name = '表名(仅修改这个即可)' ) v

 

 

二、备注

MySQL中字段名称对应的Java类型


 

posted @ 2022-06-08 11:26  淡怀  阅读(837)  评论(0编辑  收藏  举报