AUTOINCREMENT (SQLite)
AUTOINCREMENT (SQLite) is a SQL statement in the SQLite Specific category. SQLite: unlike AUTO_INCREMENT in MySQL, only INTEGER PRIMARY KEY columns auto-increment. AUTOINCREMENT guarantees unique increasing IDs. The syntax is column INTEGER PRIMARY KEY AUTOINCREMENT. It returns auto-incrementing integer. A typical example: CREATE TABLE users ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT ); -- Without AUTOINCREMENT, reusing deleted IDs is allowed -- With AUTOINCREMENT, IDs are strictly increasing (never reused) -- Note: keyword is AUTOINCREMENT (not AUTO_INCREMENT) A close relative is ROWID / _ROWID_, which sQLite: every row has an implicit 64-bit ROWID. INTEGER PRIMARY KEY becomes an alias for ROWID. A close relative is ATTACH DATABASE, which sQLite: connects another database file to the current connection, allowing cross-database queries. A close relative is PRAGMA, which sQLite: special commands to query/set database configuration, metadata, and behavior. More about this category: SQLite-specific features — AUTOINCREMENT, ATTACH, VACUUM, PRAGMA, ROWID.