0
0
PostgreSQLquery~10 mins

UUID type and generation in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a table with a UUID primary key column.

PostgreSQL
CREATE TABLE users (id [1] PRIMARY KEY);
Drag options to blanks, or click blank then click option'
AUUID
BINT
CTEXT
DSERIAL
Attempts:
3 left
💡 Hint
Common Mistakes
Using INT or SERIAL instead of UUID for unique IDs.
2fill in blank
medium

Complete the code to generate a random UUID value.

PostgreSQL
SELECT [1]();
Drag options to blanks, or click blank then click option'
Arandom_uuid
Buuid_generate_v4
Cuuid_generate_v1
Dgen_random_uuid
Attempts:
3 left
💡 Hint
Common Mistakes
Using uuid_generate_v1() which generates time-based UUIDs.
3fill in blank
hard

Fix the error in the code to insert a new row with a generated UUID.

PostgreSQL
INSERT INTO orders (order_id) VALUES ([1]());
Drag options to blanks, or click blank then click option'
Agen_random_uuid
Buuid_generate_v4
Cuuid_generate_v2
Drandom
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like uuid_generate_v2() or random().
4fill in blank
hard

Fill both blanks to create a table with a UUID primary key that defaults to a generated UUID.

PostgreSQL
CREATE TABLE sessions (session_id [1] PRIMARY KEY DEFAULT [2]());
Drag options to blanks, or click blank then click option'
AUUID
BTEXT
Cgen_random_uuid
Duuid_generate_v4
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT type or wrong default functions for UUID columns.
5fill in blank
hard

Fill all three blanks to select UUIDs from a table where the UUID is not null and order by UUID.

PostgreSQL
SELECT [1] FROM devices WHERE [2] IS NOT NULL ORDER BY [3];
Drag options to blanks, or click blank then click option'
Adevice_id
Buuid
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing different column names or using columns that don't exist.