0
0
PostgreSQLquery~10 mins

ENUM types 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 an ENUM type named 'mood' with values 'happy', 'sad', and 'neutral'.

PostgreSQL
CREATE TYPE mood AS ENUM ([1]);
Drag options to blanks, or click blank then click option'
A'happy'; 'sad'; 'neutral'
B'happy', 'sad', 'neutral'
C"happy", "sad", "neutral"
Dhappy, sad, neutral
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas.
Not quoting the ENUM values.
Using double quotes instead of single quotes.
2fill in blank
medium

Complete the code to add a column 'current_mood' of type 'mood' to the 'users' table.

PostgreSQL
ALTER TABLE users ADD COLUMN current_mood [1];
Drag options to blanks, or click blank then click option'
AENUM
BVARCHAR(10)
CTEXT
Dmood
Attempts:
3 left
💡 Hint
Common Mistakes
Using VARCHAR or TEXT instead of the ENUM type.
Using the keyword ENUM without the type name.
3fill in blank
hard

Fix the error in the code to insert a value 'excited' into the 'current_mood' column of 'users'.

PostgreSQL
INSERT INTO users (current_mood) VALUES ([1]);
Drag options to blanks, or click blank then click option'
A'excited'
Bexcited
C'happy'
D'neutral'
Attempts:
3 left
💡 Hint
Common Mistakes
Inserting a value not defined in the ENUM type.
Not quoting the value.
Using a value that is not part of the ENUM list.
4fill in blank
hard

Fill both blanks to change the ENUM type 'mood' by adding a new value 'excited' after 'happy'.

PostgreSQL
ALTER TYPE mood [1] [2] 'excited' AFTER 'happy';
Drag options to blanks, or click blank then click option'
AADD
BVALUE
CRENAME
DMODIFY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'DROP' or 'RENAME' instead of 'ADD'.
Omitting the 'VALUE' keyword.
5fill in blank
hard

Fill all three blanks to select all users whose 'current_mood' is either 'happy' or 'excited'.

PostgreSQL
SELECT * FROM users WHERE current_mood [1] ('[2]', '[3]');
Drag options to blanks, or click blank then click option'
A=
BIN
Cexcited
Dhappy
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of 'IN' for multiple values.
Not quoting the ENUM values.
Swapping the order of the ENUM values.