MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 5 - DDL (Data Definition Language)
Lesson Content Link:DEFAULT Constraint
Current Quiz Count:30
Progress
0%
Q1
True / False

The DEFAULT constraint in MySQL automatically assigns a default value to a column if no value is provided during insertion.

Q2
True / False

In MySQL, the DEFAULT constraint can only be applied to numeric columns.

Q3
True / False

In MySQL, you can add a DEFAULT constraint to an existing column using the ALTER TABLE statement.

Q4
True / False

In MySQL, the DEFAULT constraint can be used with the TIMESTAMP data type to automatically set the current date and time for new rows.

Q5
True / False

MySQL allows the DEFAULT constraint to be used with the AUTO_INCREMENT attribute.

Q6
True / False

If a column in MySQL has a DEFAULT constraint and a NULL value is inserted, the default value will be used instead of NULL.

Q7
True / False

In MySQL, you can define a DEFAULT constraint that is a result of an arithmetic operation.

Q8
True / False

In MySQL, a DEFAULT constraint can reference other columns in the same table.

Q9
True / False

In MySQL, you can set the default value of a column to be an expression involving system functions like UUID().

Q10
True / False

When exporting a MySQL database, the DEFAULT constraints on the columns are not included in the dump file.

Q11
Single Choice

What is the purpose of the DEFAULT constraint in MySQL?

Q12
Single Choice

Which of the following is the correct syntax to set a default value of 'N/A' for a column named status in MySQL?

Q13
Single Choice

What will be the default value for a column if no DEFAULT constraint is specified in MySQL?

Q14
Single Choice

How can you remove a DEFAULT constraint from a column in MySQL?

Q15
Single Choice

In MySQL, can the DEFAULT constraint be used with a BLOB or TEXT column?

Q16
Single Choice

Which of the following MySQL queries will correctly set a default value of CURRENT_TIMESTAMP for a created_at column?

Q17
Single Choice

How does the DEFAULT constraint interact with the INSERT ... ON DUPLICATE KEY UPDATE statement in MySQL?

Q18
Single Choice

Can a MySQL column have a DEFAULT value that is derived from another column?

Q19
Single Choice

Which MySQL version introduced the ability to set a default value for a JSON column?

Q20
Single Choice

Which statement about DEFAULT constraints in MySQL is true?

Q21
Multiple Choice

Identify the correct SQL statement to create a table with a column that has a default value.

SQL Code
CREATE TABLE customers (
 customer_id INT PRIMARY KEY,
 signup_date DATE DEFAULT CURRENT_DATE
);
Q22
Multiple Choice

Choose the correct SQL statement to modify an existing column to include a default value.

SQL Code
ALTER TABLE orders
MODIFY COLUMN status VARCHAR(20) DEFAULT 'Pending';
Q23
Multiple Choice

Determine the correct SQL statement to create a table where a numeric column has a default value of 0.

SQL Code
CREATE TABLE inventory (
 item_id INT PRIMARY KEY,
 quantity INT DEFAULT 0
);
Q24
Multiple Choice

Which SQL statement correctly adds a DEFAULT constraint to an existing column?

SQL Code
ALTER TABLE employees
ALTER COLUMN salary SET DEFAULT 50000;
Q25
Multiple Choice

Select the correct SQL statement to drop a DEFAULT constraint from a column.

SQL Code
ALTER TABLE orders
ALTER COLUMN status DROP DEFAULT;
Q26
Multiple Choice

Identify the correct SQL statement to create a table with multiple columns, each having a different default value.

SQL Code
CREATE TABLE accounts (
 account_id INT PRIMARY KEY,
 account_type VARCHAR(20) DEFAULT 'Checking',
 balance DECIMAL(10, 2) DEFAULT 0.00
);
Q27
Multiple Choice

Determine the correct SQL statement to set a default value for a date column to the current date.

SQL Code
CREATE TABLE subscriptions (
 subscription_id INT PRIMARY KEY,
 start_date DATE DEFAULT CURRENT_DATE
);
Q28
Multiple Choice

Which SQL statement correctly uses the DEFAULT constraint with an ENUM data type?

SQL Code
CREATE TABLE orders (
 order_id INT PRIMARY KEY,
 order_status ENUM('Pending', 'Completed', 'Canceled') DEFAULT 'Pending'
);
Q29
Multiple Choice

Select the correct SQL statement to enforce a NOT NULL constraint along with a DEFAULT constraint.

SQL Code
CREATE TABLE users (
 user_id INT PRIMARY KEY,
 email VARCHAR(100) NOT NULL DEFAULT 'example@example.com'
);
Q30
Multiple Choice

Identify the correct SQL statement to drop a DEFAULT constraint while retaining the column's NOT NULL constraint.

SQL Code
ALTER TABLE employees
ALTER COLUMN hire_date DROP DEFAULT;