Oracle数据库产生Guid

Oracle数据库产生Guid的函数

CREATE OR REPLACE FUNCTION GET_GUID

   RETURN CHAR
IS
   v_guid              CHAR (38);
   v_guid_part_one     CHAR (8);
   v_guid_part_two     CHAR (4);
   v_guid_part_three   CHAR (4);
   v_guid_part_four    CHAR (4);
   v_guid_part_five    CHAR (12);
BEGIN
   SELECT SYS_GUID ()
     INTO v_guid
     FROM DUAL;
   v_guid_part_one := SUBSTR (v_guid, 0, 8);
   v_guid_part_two := SUBSTR (v_guid, 8, 4);
   v_guid_part_three := SUBSTR (v_guid, 12, 4);
   v_guid_part_four := SUBSTR (v_guid, 16, 4);
   v_guid_part_five := SUBSTR (v_guid, 20, 12);
   v_guid :=
    CONCAT
     (CONCAT
        ('{',CONCAT
           (CONCAT
               (CONCAT
                   (CONCAT (CONCAT (CONCAT (CONCAT (CONCAT (v_guid_part_one,
                                                            '-'),
                                                    v_guid_part_two
                                                   ),
                                            '-'
                                           ),
                                    v_guid_part_three
                                   ),
                            '-'
                           ),
                    v_guid_part_four
                   ),
                '-'
               ),
            v_guid_part_five
           )
    ),
   '}'
  );
   RETURN (v_guid);
END GET_GUID;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值