SQLite Can a non-integer primary key be used?

Thanks for reading and hopefully the answer,

Due to outdated problems and company policies, I work with SQLite 2.8.17 and have several varchars as primary keys.

But when I run pragma integrity_check, it reports โ€œrowid not in the indexโ€ and โ€œthe wrong number of records in the index in the tables using varchar primary key, but the return result is OK.

Access to the extended database and its use (approximately on the day of load testing), apparently lead to the failure of the database (integrity check returns FAIL), and the only explanation (via .explain) are the same errors as before ( rowid is absent in the index and "the wrong number of entries in the index ).

Can anyone help? Something is wrong, what am I doing?

Thanks.

+4
source share
1 answer

If you vacuum the database, it should at least recreate it without this integrity check. Then try access and use day, as you say, and see if an error is present.

To clear the database, enter the database at the command prompt and enter: VACUUM; or use the command line:

 sqlite2.exe mydb.db "vacuum;" 

(although I seem to remember that SQLite2 needed a table name after VACUUM , so you might need to experiment a bit. However, this will affect all tables.)

0
source

All Articles