0
0
SQLquery~5 mins

AUTO_INCREMENT behavior in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does AUTO_INCREMENT do in a SQL table?
AUTO_INCREMENT automatically generates a unique number for a column when a new row is added, usually used for primary keys.
Click to reveal answer
intermediate
Can you insert a specific value into an AUTO_INCREMENT column?
Yes, you can insert a specific value manually, but it must not conflict with existing values to avoid errors.
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 rows 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: ALTER TABLE table_name AUTO_INCREMENT = value; where value is the new starting number.
Click to reveal answer
beginner
Why is AUTO_INCREMENT useful in real-life applications?
It helps create unique IDs automatically, like customer IDs or order numbers, so you don’t have to manage them manually.
Click to reveal answer
What type of column usually uses AUTO_INCREMENT?
AForeign key
BText column
CDate column
DPrimary key
If you insert a row without specifying the AUTO_INCREMENT column, what happens?
AThe column gets a unique incremented number automatically
BThe insert fails
CThe column is set to NULL
DThe column is set to 0
After deleting rows, what happens to the AUTO_INCREMENT counter?
AIt stays the same and continues incrementing
BIt resets to 1 automatically
CIt decreases by the number of deleted rows
DIt causes an error on next insert
How do you manually reset the AUTO_INCREMENT value in MySQL?
AUPDATE table_name SET AUTO_INCREMENT = new_value;
BALTER TABLE table_name AUTO_INCREMENT = new_value;
CRESET AUTO_INCREMENT table_name TO new_value;
DDROP AUTO_INCREMENT FROM table_name;
What happens if you try to insert a duplicate value into an AUTO_INCREMENT column?
AThe duplicate is allowed
BThe database changes the value automatically
CThe insert fails with an error
DThe row is ignored
Explain how AUTO_INCREMENT works when adding new rows to a table.
Think about how IDs are assigned automatically without you typing them.
You got /4 concepts.
    Describe how to reset the AUTO_INCREMENT counter and why you might want to do that.
    Consider when you want your IDs to start fresh or from a specific number.
    You got /3 concepts.