Oracle sql uses sys_guid() to generate 32-bit id garbled solutions

Preface 

I used the sys_guid() method to generate a 32-bit id before, but I forgot it over time. As the saying goes, "A good memory is not as good as a bad pen."

 Theme

select sys_guid() from dual;

 As you can see, the code is garbled directly.

the reason:SYS_GUID 以16位RAW类型值形式返回一个全局唯一的标识符

Solution 

Use the rawtohex() function method.

Popular science here

  • hextoraw(): Convert a hexadecimal string to raw;

  • rawtohex(): convert raw string to hexadecimal;

 Garbled resolution:

select rawtohex(sys_guid()) from dual;

As you can see, the garbled code is gone.

To lowercase:

select lower(rawtohex(sys_guid())) from dual;

 

 

Guess you like

Origin blog.csdn.net/admin123404/article/details/107763333