Search code examples
oracle-databasedb2uuid

Equivalent of oracle function SYS_GUID() in DB2 LUW?


Hello I'm using DB2/LINUXX8664 and I would like to know the equivalent of the oracle function SYS_GUID() function in DB2 LUW.

create table ab(
uuid varchar2(36) default sys_guid());

The Code above is for Oracle, do we have this built-in function in DB2?


Solution

  • Db2 LUW and IBMi both have GENERATE_UNIQUE()

    But it returns a 13 byte binary string instead of the 16 byte binary string Oracle's function does.

    In addition, Db2 doesn't support the use of a function in the DEFAULT clause for a column in a table definition.