I'd like to insert NaN values into SQLite database.
I have Ent table with Id, StringColumn and DoubleColumn (not nullable) and I try use the following SQL statement:
INSERT INTO Ent (Id, StringColumn, DoubleColumn) VALUES (1, 'NaN test', ????)
I don't know what to put in place of '????' to have NaN stored.
I'm accessing the database using System.Data.SQLite - maybe this also matters?
Following is the basic syntax of using NULL while creating a table. SQLite> CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL ); Here, NOT NULL signifies that the column should always accept an explicit value of the given data type.
Unless the column is an INTEGER PRIMARY KEY or the table is a WITHOUT ROWID table or a STRICT table or the column is declared NOT NULL, SQLite allows NULL values in a PRIMARY KEY column.
If the result is NULL, then sqlite3_column_bytes() returns zero.
The INTEGER values in SQLite are stored in either 1, 2, 3, 4, 6, or 8 bytes of storage depending on the value of the number. REAL – this storage class is used to store the floating point values, and they are stored in an 8-bytes of storage.
I've asked guys of SQLite how to deal with the problem: http://system.data.sqlite.org/index.html/tktview/e06c4caff3c433c80616ae5c6df63fc830825e59. They've added a new connection flag: "GetAllAsText" and now it is possible to store NaN, along with the others (Infinity, -Infinity).
SQLite is rather... lax... about data types. Feel free to put "NaN" into a column defined as "double". Or "infinity". Or "double", for that matter. SQLite doesn't care.
SQLite does not have a textual representation of NaN values.
In SQL, the special NULL
behaves similarly in computations, and can serve the same purpose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With