0
0
SQLquery~10 mins

DEFAULT values in SQL - Interactive Code Practice

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

Complete the code to set a default value of 0 for the column 'score'.

SQL
CREATE TABLE results (id INT, score INT [1] 0);
Drag options to blanks, or click blank then click option'
ADEFAULT
BSET
CVALUE
DASSIGN
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET instead of DEFAULT
Using VALUE or ASSIGN which are not valid here
2fill in blank
medium

Complete the code to add a new column 'status' with default value 'active'.

SQL
ALTER TABLE users ADD COLUMN status VARCHAR(10) [1] 'active';
Drag options to blanks, or click blank then click option'
AASSIGN
BVALUE
CSET
DDEFAULT
Attempts:
3 left
💡 Hint
Common Mistakes
Using VALUE or SET which are not valid in this context
Forgetting to put quotes around string default values
3fill in blank
hard

Fix the error in the code to set a default date of '2024-01-01' for the 'start_date' column.

SQL
CREATE TABLE events (id INT, start_date DATE [1] '2024-01-01');
Drag options to blanks, or click blank then click option'
AASSIGN
BDEFAULT
CVALUE
DSET
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET instead of DEFAULT
Using VALUE which is not valid here
4fill in blank
hard

Fill both blanks to create a table with a 'quantity' column defaulting to 1 and a 'status' column defaulting to 'pending'.

SQL
CREATE TABLE orders (quantity INT [1] 1, status VARCHAR(20) [2] 'pending');
Drag options to blanks, or click blank then click option'
ADEFAULT
BSET
CVALUE
DASSIGN
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET or VALUE instead of DEFAULT
Mixing different keywords for the two columns
5fill in blank
hard

Fill all three blanks to add a column 'priority' with default 5, a column 'category' with default 'general', and a column 'active' with default TRUE.

SQL
ALTER TABLE tasks ADD COLUMN priority INT [1] 5, ADD COLUMN category VARCHAR(15) [2] 'general', ADD COLUMN active BOOLEAN [3] TRUE;
Drag options to blanks, or click blank then click option'
ADEFAULT
BSET
CVALUE
DASSIGN
Attempts:
3 left
💡 Hint
Common Mistakes
Using SET or VALUE instead of DEFAULT
Forgetting to use DEFAULT for one or more columns