驼峰函数
CREATE FUNCTION `underlineToCamel`(paramString VARCHAR(200)) RETURNS varchar(200) CHARSET utf8 DETERMINISTIC begin set paramString = LOWER(paramString); set paramString = replace(paramString, '_a', 'A'); set paramString = replace(paramString, '_b', 'B'); set paramString = replace(paramString, '_c', 'C'); set paramString = replace(paramString, '_d', 'D'); set paramString = replace(paramString, '_e', 'E'); set paramString = replace(paramString, '_f', 'F'); set paramString = replace(paramString, '_g', 'G'); set paramString = replace(paramString, '_h', 'H'); set paramString = replace(paramString, '_i', 'I'); set paramString = replace(paramString, '_j', 'J'); set paramString = replace(paramString, '_k', 'K'); set paramString = replace(paramString, '_l', 'L'); set paramString = replace(paramString, '_m', 'M'); set paramString = replace(paramString, '_n', 'N'); set paramString = replace(paramString, '_o', 'O'); set paramString = replace(paramString, '_p', 'P'); set paramString = replace(paramString, '_q', 'Q'); set paramString = replace(paramString, '_r', 'R'); set paramString = replace(paramString, '_s', 'S'); set paramString = replace(paramString, '_t', 'T'); set paramString = replace(paramString, '_u', 'U'); set paramString = replace(paramString, '_v', 'V'); set paramString = replace(paramString, '_w', 'W'); set paramString = replace(paramString, '_x', 'X'); set paramString = replace(paramString, '_y', 'Y'); set paramString = replace(paramString, '_z', 'Z'); set paramString = replace(paramString, '_', ''); RETURN paramString; end
查询
SELECT c.TABLE_SCHEMA as '数据库名', c.TABLE_NAME as '表名',t.table_comment as 表中文名, c.ORDINAL_POSITION as '序号', c.COLUMN_NAME as '字段', underlineToCamel(c.COLUMN_NAME) '驼峰字段', c.COLUMN_COMMENT as '备注', -- c.DATA_TYPE as '数据类型', -- IFNULL(c.CHARACTER_MAXIMUM_LENGTH,c.numeric_precision) as '长度', if(IFNULL(c.CHARACTER_MAXIMUM_LENGTH,c.numeric_precision) is null,c.DATA_TYPE,CONCAT(c.DATA_TYPE,"(",IFNULL(c.CHARACTER_MAXIMUM_LENGTH,c.numeric_precision),")")) as 数据类型, c.IS_NULLABLE as '是否可以为空',# 是否必填 c.COLUMN_DEFAULT as '默认值', case c.column_key when 'PRI' then '是' ELSE '' end '是否主键' from information_schema.columns c LEFT JOIN information_schema.TABLES t on c.TABLE_SCHEMA = t.TABLE_SCHEMA and c.TABLE_NAME = t.TABLE_NAME where 1=1