Mysql 自定义函数-下划线转驼峰

直接在navicate或者服务器上执行
1.创建函数:

    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

2.删除函数:

	drop function underlineToCamel; 

3.示例语句

	select underlineToCamel('CPTJFL_KHDX') from dual 

4.执行结果
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值