Database / SQLite Interview questions
What is a PRIMARY KEY in SQLite?
A PRIMARY KEY uniquely identifies each row in a table, and SQLite enforces that no two rows
can share the same primary key value (unless declared otherwise for special cases like
WITHOUT ROWID tables).
CREATE TABLE person ( id INTEGER PRIMARY KEY, name TEXT );
A notable SQLite-specific detail: declaring a column as INTEGER PRIMARY KEY (exactly that
type, singular) makes that column an alias for the table's internal rowid — the fastest
possible way to look up a row, since it directly maps to SQLite's internal B-tree key rather than requiring a
separate index lookup.
More Related questions...