From the documentation:
Reals are stored as 8 bytes:
REAL. The value is a floating point value, stored as an 8-byte IEEE floating point number.
RowID are also 8 bytes / 64 bits
All rows within SQLite tables have a 64-bit signed integer key that uniquely identifies the row within its table
And thus have a feature where you can take an INTEGER column and have it work as the RowID as well
If a rowid table has a primary key that consists of a single column and the declared type of that column is "INTEGER" in any mixture of upper and lower case, then the column becomes an alias for the rowid. Such a column is usually referred to as an "integer primary key".
Which is important if you consider:
The data for rowid tables is stored as a B-Tree structure containing one entry for each table row, using the rowid value as the key. This means that retrieving or sorting records by rowid is fast. Searching for a record with a specific rowid, or for all records with rowids within a specified range is around twice as fast as a similar search made by specifying any other PRIMARY KEY or indexed value.
I am building a key-value store library in Qt/C++ with SQLITE as the backend, where any of the INTEGER, REAL, BLOB, TEXT datatypes are available as keys. With INTEGER and REAL being 64 bit, I'd like to take advantage of the rowid performance increase, considering they are both 8 byte.
SQLITE however only specifies that INTEGER can be used.
Questions:
- Can REAL serve as an alias for the rowid?
- If no, Why not exactly? Is it just an oversight from SQLITE developers, or is there a technical reason this can't be done?
- If no, how would I go about doing this on Qt, where I convert the
doubleinto along long intby way of its byte signature, and not by way of its value?
Thanks.




No
Besides, SQLite doesn't really have column types. Row IDs are always integers, no matter what. Even if the column was labelled as REAL, they would still be integer values. You can store any data type in any column in SQLite.
Convert it in your own program code, when reading rows from the database.