Auto-Increment
An auto-increment column is a numeric column whose value is generated by the database engine on insert, typically by adding one to the previous highest value. It is the most common way to build a surrogate primary key, since the application never has to compute or coordinate the value itself.
MySQL uses the AUTO_INCREMENT column option, PostgreSQL uses SERIAL or an IDENTITY column, and SQLite uses AUTOINCREMENT. Laravel’s migration id() and increments() helpers, and Doctrine’s autoincrement column option, both generate this kind of column.
Because the values are sequential and predictable, auto-increment identifiers exposed in a URL or an API response let an attacker enumerate every record of a resource by walking the integer range, a form of insecure direct object reference. They also leak the approximate row count and growth rate of a table to anyone who can read two consecutive IDs. This is one of the reasons applications obfuscate the value or use a UUID or ULID as the public-facing identifier instead, while keeping the auto-increment integer as the internal primary key for indexing efficiency.
Auto-increment values are not guaranteed to be gap-free: a rolled-back transaction or a deleted row still consumes a value, so the sequence should never be relied upon to reflect an exact count.
<?php
// Laravel migration
Schema::create('projects', function (Blueprint $table) {
$table->id(); // BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY
});
?>