Interview Question

What is auto increment?

MySQL AUTO_INCREMENT generates numeric column values and may leave gaps.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

AUTO_INCREMENT is a MySQL column attribute that generates the next numeric value for inserted rows. • It is commonly used on an indexed integer identifier column. • An explicit value can affect the next generated value according to MySQL rules. • Generated values can have gaps and should not be used as gapless business numbering.

💡 SQL Example

CREATE TABLE users (user_id bigint NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(100) NOT NULL);

Result

CREATE TABLE

⚡ Quick Revision

MySQL AUTO_INCREMENT generates numeric column values and may leave gaps.