SQL Language Guide : 3. Elements of SQL Statements : SQL Functions : UUID ([expr]) Function
 
Share this page                  
UUID ([expr]) Function
With no parameters, the UUID() function creates a 128-bit universal unique identifier (UUID).
> createdb uuiddb
> sql uuiddb
* CREATE TABLE uuidtable (u1 UUID, u2 BYTE(16));
* INSERT INTO uuidtable VALUES (UUID(), UUID());
//
// Verify the length in byte format
//
* SELECT LENGTH(u1) FROM uuidtable;
//
//Length of u1 will be 36 bytes representing the length of the ASCII representation
//Length of u2 will be 16 bytes, the length of the BYTE(16) representation
//
With a parameter, UUID (expr) will convert that parameter to a UUID if possible. Character string data types must follow the 36-byte ASCII HEX format including the hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
UUIDs stored as BYTE(16) can be readily converted into the UUID data type.