Huge (20 digits) Primary keys and SQLite
-
03-07-2019 - |
Question
If I try to insert data with a 20 digit primary key into a SQLite database I get an error with the second insert statement because it "is not unique". If I select the values I can see from the SQLite commandprompt that the primary key is written in scientific notation. The column type is decimal. Is there a way to force SQLite to insert the values "as they are" keeping the precision / "normal representation" even with values that long?
Solution
insert it as a 'string', not a number.
OTHER TIPS
the primary key field must be an integer, the largest value is 9223372036854775807. use a separate (indexed) field, and insert the value as string.
Strange, sounds like your wrapper is putting the number in as a float. I thought DECIMAL was mapped to an integer internally. Using a string would work but may be slow do to the indexing of the string rather than an int.