[PL/SQL] How to generate UUID

[PL/SQL] How to generate UUID

The UUID (Universally Unique Identifier) is a 128-bit number represented as five sequences of hex digits separated by dashes. It may be used to identify some information like message, record or object identifier.

Below is an example of UUID. More about UUID and it’s history you can find here.

 

How to implement UUID in PL/SQL

Oracle Database hasn’t implemented UUID function yet, but there is a similar function called sys_guid(). The functions returns GUID which is a 128-bit number represented as sequence of hex digits without dashes. The idea to make UUID from GUID is very simple – you have to just insert dashes into right places. Below is an example of function which converts sys_guid() to UUID.

 

If you think this tutorial is valuable, please leave me +1  or share it. This action will allow me to reach a wider audience.

Thank you.

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu