SQLite: data type depends on quotes?

In SQLite, the value data type is associated with the value itself, and not with the column type. Suppose we have a table with the integer id of the primary key and the integer column some_number. If I make such a request:

INSERT INTO mytable (id, some_number) VALUES (NULL, "1234")

Will 123 be inserted as an integer or as a string? What will be the consequences for me, say, when I compare it with another value like "234" (like the number 1234> 234, like the string "1234" <234?)?

+3
source share
2 answers

if your field type (some_number) is numeric, then it will be inserted as a numeric value. Regardless of whether you put quotation marks.

if some_numeber is numeric

INSERT INTO mytable (id, some_number) VALUES (NULL, "1234")

and

INSERT INTO mytable (id, some_number) VALUES (NULL, 1234)

are the same

+4

.

+2

Source: https://habr.com/ru/post/1782230/


All Articles