0
0
SQLquery~10 mins

NOT NULL constraint 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 add a NOT NULL constraint to the 'name' column.

SQL
ALTER TABLE employees MODIFY COLUMN name [1];
Drag options to blanks, or click blank then click option'
AVARCHAR(50) NOT NULL
BVARCHAR(50)
CINT NOT NULL
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to specify the data type when modifying the column.
Using a wrong data type like INT for a name column.
2fill in blank
medium

Complete the code to create a table where 'email' cannot be NULL.

SQL
CREATE TABLE users (id INT PRIMARY KEY, email [1]);
Drag options to blanks, or click blank then click option'
AVARCHAR(100)
BINT NOT NULL
CTEXT
DVARCHAR(100) NOT NULL
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting NOT NULL, allowing NULL emails.
Using INT type for email.
3fill in blank
hard

Fix the error in the code to add a NOT NULL constraint to 'age'.

SQL
ALTER TABLE persons MODIFY age [1];
Drag options to blanks, or click blank then click option'
AINT NOT NULL
BVARCHAR(3) NOT NULL
CINT
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Specifying only NOT NULL without data type.
Using wrong data type like TEXT for age.
4fill in blank
hard

Fill both blanks to create a table where 'username' and 'password' cannot be NULL.

SQL
CREATE TABLE accounts (username [1], password [2]);
Drag options to blanks, or click blank then click option'
AVARCHAR(30) NOT NULL
BVARCHAR(30)
CTEXT NOT NULL
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving one column without NOT NULL.
Using TEXT without NOT NULL.
5fill in blank
hard

Fill all three blanks to add NOT NULL constraints to 'title', 'author', and 'year' columns.

SQL
CREATE TABLE books (title [1], author [2], year [3]);
Drag options to blanks, or click blank then click option'
AVARCHAR(100) NOT NULL
BVARCHAR(50) NOT NULL
CINT NOT NULL
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT without NOT NULL.
Using wrong data types for columns.