0
0
MySQLquery~10 mins

ENUM and SET types in MySQL - Interactive Code Practice

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

Complete the code to define a column named 'status' with ENUM type having values 'active' and 'inactive'.

MySQL
CREATE TABLE users (id INT, status ENUM([1]));
Drag options to blanks, or click blank then click option'
A'open', 'closed'
B'yes', 'no'
C'active', 'inactive'
D'true', 'false'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to quote the ENUM values.
Using values not related to the column meaning.
2fill in blank
medium

Complete the code to define a SET column named 'features' that can include 'wifi', 'parking', and 'pool'.

MySQL
CREATE TABLE hotels (id INT, features SET([1]));
Drag options to blanks, or click blank then click option'
A'wifi', 'parking', 'pool'
B'wifi', 'parking'
C'wifi', 'pool'
D'parking', 'pool'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out one or more allowed values.
Using ENUM instead of SET for multiple selections.
3fill in blank
hard

Fix the error in the ENUM definition for a column 'priority' with values 'low', 'medium', 'high'.

MySQL
CREATE TABLE tasks (id INT, priority ENUM([1]));
Drag options to blanks, or click blank then click option'
Alow, medium, high
B'low', 'medium', high
C'low', medium, 'high'
D'low', 'medium', 'high'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting all ENUM values.
Mixing quoted and unquoted values.
4fill in blank
hard

Fill both blanks to create a table with a SET column 'options' allowing 'red', 'green', and 'blue', and a default value of 'red'.

MySQL
CREATE TABLE colors (id INT, options SET([1]) DEFAULT [2]);
Drag options to blanks, or click blank then click option'
A'red', 'green', 'blue'
B'red'
C'green'
D'blue'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting default value not in the SET list.
Forgetting quotes around default value.
5fill in blank
hard

Fill all three blanks to define a table with an ENUM column 'level' with values 'beginner', 'intermediate', 'advanced', a SET column 'skills' with 'sql', 'python', 'java', and default 'beginner' for 'level'.

MySQL
CREATE TABLE learners (id INT, level ENUM([1]) DEFAULT [2], skills SET([3]));
Drag options to blanks, or click blank then click option'
A'beginner', 'intermediate', 'advanced'
B'beginner'
C'sql', 'python', 'java'
D'expert'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a default value not in ENUM list.
Mixing up ENUM and SET values.