Recall & Review
beginner
What does the AUTO_INCREMENT attribute do in MySQL?
It automatically generates a unique number for a column when a new row is inserted, usually used for primary keys.
Click to reveal answer
intermediate
Can you manually insert a value into an AUTO_INCREMENT column?
Yes, you can insert a specific value manually, but it must not conflict with existing values or the next auto-generated value.
Click to reveal answer
intermediate
What happens if you delete the last row with the highest AUTO_INCREMENT value?
The AUTO_INCREMENT counter does not decrease automatically; new inserts continue from the last highest value plus one.
Click to reveal answer
advanced
How can you reset the AUTO_INCREMENT counter in MySQL?
You can reset it using the command:
ALTER TABLE table_name AUTO_INCREMENT = value; where value is the new starting number.Click to reveal answer
advanced
Does AUTO_INCREMENT guarantee no gaps in the sequence of generated numbers?
No, gaps can occur due to deleted rows or rolled-back transactions, so AUTO_INCREMENT values are unique but not always consecutive.
Click to reveal answer
What is the default behavior of AUTO_INCREMENT in MySQL when inserting a new row?
✗ Incorrect
AUTO_INCREMENT automatically assigns the next unique number for the column.
If you delete the row with the highest AUTO_INCREMENT value, what happens to the next inserted row's AUTO_INCREMENT value?
✗ Incorrect
The counter does not decrease; it continues from the last highest value plus one.
How do you reset the AUTO_INCREMENT counter to start from 100 in a table named 'users'?
✗ Incorrect
The correct syntax is ALTER TABLE users AUTO_INCREMENT = 100;
Can AUTO_INCREMENT columns have gaps in their sequence?
✗ Incorrect
Gaps can happen because of deleted rows or rolled-back transactions.
Which data type is commonly used with AUTO_INCREMENT columns?
✗ Incorrect
AUTO_INCREMENT is typically used with integer types to generate unique numbers.
Explain how AUTO_INCREMENT works in MySQL and what happens when rows are deleted.
Think about how MySQL keeps track of the next number to assign.
You got /4 concepts.
Describe how to reset the AUTO_INCREMENT value and why you might want to do that.
Consider the SQL command that changes table structure.
You got /3 concepts.