CREATE OR REPLACE FUNCTION NEWUUID()
RETURNS CHAR(36)
BEGIN
    DECLARE @UUID CHAR(32);
    SET @UUID=LOWER(HEX(RAND()*255) || HEX(RAND()*255));
    RETURN LEFT(@UUID,8)||'-'||
        SUBSTR(@UUID,9,4)||'-'||
        SUBSTR(@UUID,13,4)||'-'||
        SUBSTR(@UUID,17,4)||'-'||
        RIGHT(@UUID,12);
END
/

ALTER TABLE UM_TENANT ADD COLUMN UM_TENANT_UUID VARCHAR(36) NOT NULL DEFAULT 'NONE'
/

CALL SYSPROC.ADMIN_CMD('REORG TABLE UM_TENANT')
/

UPDATE UM_TENANT SET UM_TENANT_UUID = NEWUUID()
/

CALL SYSPROC.ADMIN_CMD('REORG TABLE UM_TENANT')
/

ALTER TABLE UM_TENANT ADD UNIQUE (UM_TENANT_UUID)
/

CALL SYSPROC.ADMIN_CMD('REORG TABLE UM_TENANT')
/
