Complete the code to create a table with a UUID primary key column.
CREATE TABLE users (id [1] PRIMARY KEY);The UUID type stores universally unique identifiers, perfect for unique keys.
Complete the code to generate a random UUID value.
SELECT [1]();uuid_generate_v1() which generates time-based UUIDs.gen_random_uuid() generates a random UUID (version 4) in PostgreSQL.
Fix the error in the code to insert a new row with a generated UUID.
INSERT INTO orders (order_id) VALUES ([1]());uuid_generate_v2() or random().gen_random_uuid() is the correct function to generate a random UUID for insertion.
Fill both blanks to create a table with a UUID primary key that defaults to a generated UUID.
CREATE TABLE sessions (session_id [1] PRIMARY KEY DEFAULT [2]());
The session_id column should be of type UUID and default to gen_random_uuid() to auto-generate unique IDs.
Fill all three blanks to select UUIDs from a table where the UUID is not null and order by UUID.
SELECT [1] FROM devices WHERE [2] IS NOT NULL ORDER BY [3];
We select the device_id column, filter where it is not null, and order by the same column.