MySQL Database Quiz Questions

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

In MySQL, the AUTO_INCREMENT attribute can be applied to any column.

Q2
True / False

In MySQL, only one column per table can be assigned the AUTO_INCREMENT attribute.

Q3
True / False

The AUTO_INCREMENT value in MySQL starts at 1 by default.

Q4
True / False

In MySQL, you can set the initial value for an AUTO_INCREMENT column using the AUTO_INCREMENT table option.

Q5
True / False

The AUTO_INCREMENT attribute in MySQL can be used with VARCHAR data type columns.

Q6
True / False

In MySQL, deleting the highest-numbered row in an AUTO_INCREMENT column and then inserting a new row will reuse the deleted number.

Q7
True / False

MySQL’s AUTO_INCREMENT attribute can be used in conjunction with the PARTITION feature.

Q8
True / False

In MySQL, if the AUTO_INCREMENT column reaches its maximum value, it will automatically reset to 1.

Q9
True / False

In MySQL, you can reset the AUTO_INCREMENT value of a table without deleting any rows.

Q10
True / False

In MySQL, using INSERT IGNORE with an AUTO_INCREMENT column will skip rows that would cause a duplicate key error and continue to increment the AUTO_INCREMENT value.

Q11
Single Choice

What is the primary use of the AUTO_INCREMENT attribute in MySQL?

Q12
Single Choice

Which MySQL data type is commonly used with AUTO_INCREMENT?

Q13
Single Choice

How do you set a column to auto increment in a MySQL table creation statement?

Q14
Single Choice

What happens if you insert a row with a NULL value in an AUTO_INCREMENT column in MySQL?

Q15
Single Choice

Can you have more than one AUTO_INCREMENT column in a MySQL table?

Q16
Single Choice

How do you reset the AUTO_INCREMENT value for a table in MySQL?

Q17
Single Choice

How can you retrieve the current AUTO_INCREMENT value for a specific table in MySQL?

Q18
Single Choice

If an AUTO_INCREMENT column is dropped and recreated, what happens to the increment value in MySQL?

Q19
Single Choice

Which MySQL statement can affect the AUTO_INCREMENT value due to deletion of rows?

Q20
Single Choice

In MySQL, which statement would correctly alter an existing column to add the AUTO_INCREMENT attribute?

Q21
Multiple Choice

Identify the correct SQL statement to create a table with an AUTO_INCREMENT primary key.

SQL Code
CREATE TABLE employees (
 employee_id INT AUTO_INCREMENT PRIMARY KEY,
 employee_name VARCHAR(100)
);
Q22
Multiple Choice

Choose the correct SQL statement to add an AUTO_INCREMENT column to an existing table.

SQL Code
ALTER TABLE orders
ADD COLUMN order_id INT AUTO_INCREMENT PRIMARY KEY;
Q23
Multiple Choice

Determine the correct SQL statement to reset the AUTO_INCREMENT value of a table to start from a specific number.

SQL Code
ALTER TABLE products
AUTO_INCREMENT = 100;
Q24
Multiple Choice

Which SQL statement correctly uses AUTO_INCREMENT for a non-primary key column?

SQL Code
CREATE TABLE inventory (
 item_id INT PRIMARY KEY,
 serial_number INT AUTO_INCREMENT,
 product_name VARCHAR(100)
);
Q25
Multiple Choice

Select the correct SQL statement to ensure that an AUTO_INCREMENT column starts at 1 by default.

SQL Code
CREATE TABLE accounts (
 account_id INT AUTO_INCREMENT PRIMARY KEY,
 balance DECIMAL(10, 2)
);
Q26
Multiple Choice

Determine the correct SQL statement to enforce an AUTO_INCREMENT constraint on a new table while setting the initial value.

SQL Code
CREATE TABLE memberships (
 membership_id INT AUTO_INCREMENT PRIMARY KEY,
 start_date DATE,
 AUTO_INCREMENT = 500
);
Q27
Multiple Choice

Which SQL statement correctly modifies an existing AUTO_INCREMENT column to start from a higher value?

SQL Code
ALTER TABLE invoices
AUTO_INCREMENT = 1000;
Q28
Multiple Choice

Identify the correct SQL statement to reset the AUTO_INCREMENT value after deleting rows from a table.

SQL Code
ALTER TABLE orders
AUTO_INCREMENT = 1;
Q29
Multiple Choice

Select the correct SQL statement to ensure an AUTO_INCREMENT column increments by 2 instead of 1.

SQL Code
SET @@auto_increment_increment = 2;
CREATE TABLE subscriptions (
 subscription_id INT AUTO_INCREMENT PRIMARY KEY,
 subscriber_name VARCHAR(100)
);
Q30
Multiple Choice

Determine the correct SQL statement to ensure that the AUTO_INCREMENT column does not reuse numbers after deletion.

SQL Code
ALTER TABLE reservations
AUTO_INCREMENT = 500;