UUID_GENERATE

Returns a new universally unique identifier (UUID) that is generated based on high-quality randomness from /dev/urandom.

Behavior Type

Volatile

Syntax

UUID_GENERATE()

Example

=> CREATE TABLE Customers(
   cust_id UUID DEFAULT(SELECT uuid_generate()), 
   lname VARCHAR(36), 
   fname VARCHAR(24));
CREATE TABLE
=> INSERT INTO Customers VALUES (DEFAULT, 'Kearney', 'Thomas');
 OUTPUT
--------
      1
(1 row)

=> INSERT INTO Customers VALUES (DEFAULT, 'Pham', 'Duc');
 OUTPUT
--------
      1
(1 row)

=> COMMIT;
COMMIT
=> SELECT * FROM Customers;
               cust_id                |  lname  | fname
--------------------------------------+---------+--------
 34462732-ed56-4983-8f3b-e735b0c32d50 | Kearney | Thomas
 cede66b7-3d29-4da6-b700-871fc0ac57be | Pham    | Duc
(2 rows)

 

 


Was this topic helpful?