SQLite inserts a bool value

I need to insert a BOOL value into an SQLite table. If you have any thoughts or sample code, share it.

+6
source share
2 answers

From http://www.sqlite.org/datatype3.html :

SQLite does not have a separate Boolean storage class. Instead, boolean values ​​are stored as integers 0 (false) and 1 (true).

+18
source

SQLite can recognize BOOL as a type, but it is stored as a whole, which is rightly referred to by Oli Charlworth.

However, using the BOOL keyword will still work:

 CREATE TABLE YourTable( isBool BOOL NOT NULL DEFAULT 0, ); INSERT INTO YourTable (isBool) VALUES (1); INSERT INTO YourTable (isBool) VALUES (4); SELECT * FROM YourTable; isBool ---------- 1 4 

4 will be added to YourTable

+11
source

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


All Articles