On 16 Apr 2011, at 6:40pm, Tobias Vesterlund wrote:

> If I do:
> INSERT INTO Tg (TgConfigId) VALUES (1);
> 
> The following select works:
> SELECT * FROM Tg WHERE TgConfigId = 1;
> 
> But if I insert '1' instead I have to select on '1', 1 no longer works. That 
> makes some sense, but not entirely, as what I inserted isn't an integer any 
> longer but a string. Why would I be allowed to insert values with '' in a 
> column that is specified to be an integer?

Your question is good, and the answer is explained in the documentation: 
section 2.0 of

<http://www.sqlite.org/datatype3.html>

Executive summary: the type of a column is more a guideline than a rule, and 
you can store data of any kind in any column of a SQLite table.

Interestingly, had you declared that column as NUMERIC instead of INTEGER, your 
assumption about how things are handled would have been correct: SQLite would 
have done the conversion you expected.  An example of this can be found in 
section 3.4 of the same page.

Simon.


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to