How to Generate UUIDs in PostgreSQL

loading views

To generate UUIDs in PostgreSQL the UUID extension has to get activated first.

This can be done using the following command:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

After this the extension is available and can get used via uuid_generate_v4(); to create a UUIDv4.

Input

select uuid_generate_v4();

Output

uuid_generate_v4()
af9cac36-5e68-4e1e-a47c-063fce565b05