生成实体属性
SELECT
CONCAT(
'private ',
(CASE data_type
WHEN 'varchar' THEN
'String ' WHEN 'tinyint' THEN 'int ' else CONCAT(DATA_TYPE,' ') END),
column_name,
'; //',
column_comment
)
from information_schema.columns
WHERE
table_name = '表名'
AND table_schema = '数据库名';
生成查询字段
SELECT
group_concat(
column_name
)
from information_schema.columns
WHERE
table_name = '表名'
AND table_schema = '数据库名';
生成更新语句
SELECT
CONCAT("update 表名 set ",group_concat(
CONCAT(column_name," = ")
))
from information_schema.columns
WHERE
table_name = '表名'
AND table_schema = '数据库名';