[Solved] Oracle sql Use sys_guid() to Generate 32-bit id garbled

The main question
select sys_guid() from dual;

 

As you can see, the code is directly messed up.

Reason: SYS_GUID returns a globally unique identifier in the form of a 16-bit RAW type value

Solution:
Use the rawtohex() function method.

 

hextoraw(): convert a hexadecimal string to raw.

rawtohex(): convert raw string to hexadecimal.

Messy code solution.

select rawtohex(sys_guid()) from dual;

 

You can see that the garbled code is gone.

To lowercase.
select lower(rawtohex(sys_guid())) from dual;

Similar Posts: