Q:

Does SQLite's VACUUM preserve key relations?

PRAGMA foreign_keys is enabled.
Table foo has no explicit INTEGER PRIMARY KEY.
Table bar has foo_rowid INTEGER with FOREIGN KEY (foo_rowid) REFERENCES foo(rowid).
Row f in foo has a rowid of x and row b in bar has a foo_rowid of x.
If VACUUM changes f's rowid to y, does it change b's foo_rowid to y?

The VACUUM command may change the ROWIDs of entries in any tables that do not have an explicit INTEGER PRIMARY KEY.

A:

This is impossible because a rowid cannot be referenced by another table. If a column can be referenced by a foreign key, it cannot be changed by VACUUM.

