SQLite Forum

Primary Key v Unique Index
Login
If I do this

CREATE TABLE t(id INTEGER PRIMARY KEY, .... );

then id is the same as rowid.

If I do this

CREATE TABLE t(id INTEGER, ...);

CREATE UNIQUE INDEX id on t(id);

is that the same thing or is id different from rowid.

If the latter, is it possible to add a primary key after the fact? From what I've read I would guess not but I keep reading it's faster to build indexes after inserting large amounts of data but that wouldn't be possible in the case of an INTEGER PRIMARY KEY.