By default, SQLite tables have a special rowid column that uniquely identifies each row. This rowid exists even if you have a user-specified PRIMARY KEY on the table. How this rowid column behaves is influenced by your PRIMARY KEY type.

Integer Primary Keys: If you have an integer primary key, then the primary key column becomes an alias for the special rowid column. The rowid and your user-defined primary key are literally just the same column.

Taking an example:

CREATE TABLE IF NOT EXISTS users(
user_id INTEGER PRIMARY KEY,
email TEXT,
);

In this case, since we’ve defined user_id to be an INTEGER PRIMARY KEY, user_id becomes an alias for rowid. These two labels refer to the same physical column.

Figure 1: Integer primary keys are aliase…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help