oracle生成uuid

select sys_guid() from dual;

-->78AE331ADB2B4CE7AB598B1317B39D58


但该函数如下问题:
     1.返回类型为RAW
     2.没有- (dash)分隔符
     3.返回的字母大写

为了使产生的uuid符合rfc 4122的标准
创建函数如下,测试通过。

create or replace function get_uuid return varchar2 is
  v_uuid varchar(36);
begin
  v_uuid := lower(rawtohex(sys_guid()));
  v_uuid := substr(v_uuid, 1, 8) || ‘-‘ || substr(v_uuid, 9, 4) || ‘-‘ ||
            substr(v_uuid, 13, 4) || ‘-‘ || substr(v_uuid, 17, 4) || ‘-‘ ||
            substr(v_uuid, 21, 12);
  return v_uuid;
end get_uuid;

select get_uuid() from dual ;
-->7bb0152a-4c5c-4078-a1b8-f57ae58254e5

oracle生成uuid

上一篇:Mysql启动失败 MYSQL:The server quit without updating PID file


下一篇:Install Oracle 10g on Red Hat Linux 5.3 Step by Step