开发者

SQLite inserting bool value

开发者 https://www.devze.com 2023-04-03 01:41 出处:网络
I need to insert BOOL value into SQLite table. If you have any thoughts开发者_如何学JAVA, or sample code please share.From http://www.sqlite.org/datatype3.html:

I need to insert BOOL value into SQLite table. If you have any thoughts开发者_如何学JAVA, or sample code please share.


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


SQLite can recognize the BOOL as a type, however it is stored as an integer rightfully mentioned by Oli Charlesworth.

However using the BOOL keyword would 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 would still be added to YourTable

0

精彩评论

暂无评论...
验证码 换一张
取 消