转载

mysql下划线转驼峰函数

函数

CREATE FUNCTION `underlineToCamel`(paramString VARCHAR(200)) RETURNS varchar(200) CHARSET utf8
 DETERMINISTIC
begin
 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

使用方法

update t_dp_table_column_config set en_name =underlineToCamel(en_name);
 
正文到此结束
Loading...