Pergunta

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?

Foi útil?

Solução

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).

Outras dicas

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.

The trick that I currently employ is to store -Infinity on Real columns when null won't suffice or is not allowed (since you have "not null" on that column).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top