Oracle里面用RAW(16)保存SYS_GUID()的结果,不过字节顺序(byte order)和标准的GUID不同。如下

标准GUID: 265B113F-0E9D-F44D-A9D4-18BC4D3E836C

RAW(16) : 3F115B26 9D0E 4DF4 A9D4 18BC4D3E836C (实际没有空格,这里是为了显示方便)

为了方便查看,可以用正则表达式进行简单的转换。

SELECT Regexp_Replace(Lower(Sys_Guid()),
                       '(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})(.{4})',
                       '\4\3\2\1-\6\5-\8\7-\9-') AS Dummy
FROM   Dual
CONNECT BY Rownum <= 20;