MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:NUll vs NOT NULL
Current Quiz Count:30
Progress
0%
Q1
Single Choice

Which keyword is used to specify that a column can have no value in MySQL?

Q2
Single Choice

What is the default value of a column if no value is specified and the column is defined as NULL in MySQL?

Q3
Single Choice

In MySQL, which clause is used to ensure a column must always have a value?

Q4
Single Choice

What will be the result of the following MySQL query: SELECT IFNULL(NULL, 'Value');?

Q5
Single Choice

How do you modify a column to allow NULL values in MySQL?

Q6
Single Choice

In MySQL, which function can be used to replace NULL values with a specified value?

Q7
Single Choice

Which of the following statements is true about NULL values in MySQL?

Q8
Single Choice

What is the result of the following MySQL query: SELECT COUNT(*) FROM table WHERE column IS NULL;?

Q9
Single Choice

Which MySQL function is used to return NULL if the two expressions are equal?

Q10
Single Choice

Which of the following SQL queries correctly finds rows where the email column is NOT NULL in a MySQL database?

Q11
True / False

In MySQL, a column defined as NOT NULL can never contain a NULL value.

Q12
True / False

In MySQL, you can use the IS NULL keyword to check if a value is NULL.

Q13
True / False

In MySQL, NULL is the same as an empty string or zero.

Q14
True / False

In MySQL, using IS NOT NULL in a query filters out all NULL values.

Q15
True / False

MySQL's COUNT(*) function counts NULL values in a column.

Q16
True / False

In MySQL, the COALESCE function returns the first non-NULL value from its arguments.

Q17
True / False

In MySQL, the IFNULL function can be used to replace NULL values with a specified value.

Q18
True / False

In MySQL, an index can be created on columns that contain NULL values.

Q19
True / False

In MySQL, the NULLIF function returns NULL if the two arguments are equal, otherwise it returns the first argument.

Q20
True / False

In MySQL, a column with a default value of NULL will automatically be assigned a value if no value is provided during an insert operation.

Q21
Multiple Choice

Identify the correct SQL statement to create a table with a column that allows NULL values.

SQL Code
CREATE TABLE employees (
 employee_id INT PRIMARY KEY,
 middle_name VARCHAR(50) NULL
);
Q22
Multiple Choice

Select the correct SQL statement to modify a column to NOT allow NULL values.

SQL Code
ALTER TABLE orders
MODIFY COLUMN order_date DATE NOT NULL;
Q23
Multiple Choice

Determine the correct SQL statement to create a table with a column that must have a value.

SQL Code
CREATE TABLE products (
 product_id INT PRIMARY KEY,
 product_name VARCHAR(100) NOT NULL
);
Q24
Multiple Choice

Which SQL statement correctly sets a column's default value to NULL?

SQL Code
ALTER TABLE users
MODIFY COLUMN last_login TIMESTAMP NULL DEFAULT NULL;
Q25
Multiple Choice

Choose the correct SQL statement to check if a column allows NULL values.

SQL Code
SHOW COLUMNS FROM customers
WHERE Field = 'email';
Q26
Multiple Choice

Identify the correct SQL statement to create a table with multiple NOT NULL columns.

SQL Code
CREATE TABLE orders (
 order_id INT PRIMARY KEY,
 customer_id INT NOT NULL,
 order_date DATE NOT NULL,
 total_amount DECIMAL(10, 2) NOT NULL
);
Q27
Multiple Choice

Select the correct SQL statement to modify a table by adding a NOT NULL constraint to an existing column.

SQL Code
ALTER TABLE inventory
MODIFY COLUMN stock_quantity INT NOT NULL;
Q28
Multiple Choice

Determine the correct SQL statement to drop a NOT NULL constraint from a column.

SQL Code
ALTER TABLE employees
MODIFY COLUMN middle_name VARCHAR(50) NULL;
Q29
Multiple Choice

Which SQL statement correctly creates a table with a default value of NULL for a column?

SQL Code
CREATE TABLE contacts (
 contact_id INT PRIMARY KEY,
 email VARCHAR(100) DEFAULT NULL
);
Q30
Multiple Choice

Choose the correct SQL statement to enforce a NOT NULL constraint on a column during table creation.

SQL Code
CREATE TABLE payments (
 payment_id INT PRIMARY KEY,
 amount DECIMAL(10, 2) NOT NULL,
 payment_date DATE NOT NULL
);