UUID Generation Methods
UUID Generation Methods is a SQL function in the PostgreSQL Specific category. PostgreSQL UUID generation: gen_random_uuid() (pgcrypto or built-in 13+), uuid_generate_v4() (uuid-ossp). The syntax is SELECT gen_random_uuid();. It accepts see syntax. It returns uUID value. A typical example: -- PostgreSQL 13+ (built-in): SELECT gen_random_uuid(); -- 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' -- With extension: CREATE EXTENSION IF NOT EXISTS pgcrypto; SELECT gen_random_uuid(); -- MySQL: SELECT UUID(); -- 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' SELECT UUID_SHORT(); -- 987654321234567890 (integer) -- SQL Server: SELECT NEWID(); -- 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' SELECT NEWSEQUENTIALID(); -- Sequential GUID A close relative is SERIAL, which postgreSQL auto-increment type. Creates an INTEGER column with a sequence. Equivalent to AUTO_INCREMENT in MySQL. A close relative is RETURNING, which postgreSQL extension that returns values from INSERT/UPDATE/DELETE statements (like OUTPUT in SQL Server). A close relative is ARRAY, which postgreSQL supports array columns and array operations. Can be multi-dimensional. More about this category: PostgreSQL-specific features — SERIAL, RETURNING, ARRAY, JSONB, UPSERT.