Small Test of the boolean Type of sqlite Database

Source: Internet
Author: User
There is no single Boolean Storage Class in the sqlite database, and the Booean value is stored in integers 0 (false) and 1 (true). In my practice, there are three statuses of boolean, 0 (false) 1 (true) and null, as shown in, can be successfully inserted after the following insert statement, test. in addition, you can use the select * fromstuwhereflag Database

There is no single Boolean Storage Class in the sqlite database, and the Booean value is stored in integers 0 (false) and 1 (true). In my practice, there are three statuses of boolean, 0 (false) 1 (true) and null, as shown in, can be successfully inserted after the following insert statement, test. in addition, you can select * from stu where flag = Database

There is no single Boolean Storage Class in the sqlite database, and the Booean value is stored in integers 0 (false) and 1 (true). In my practice, there are three statuses of boolean, 0 (false) 1 (true) and null, as shown in,

The following insert statement can be successfully inserted.

Select * from stu where flag = "Database"

The row named a9 is queried.

Insert into stu (name, flag) values ('a1', 'true'); -- 0

Insert into stu (name, flag) values ('a2 ', 'ture'); -- 0

Insert into stu (name, flag) values ('a3 ', 1); -- 1

Insert into stu (name, flag) values ('a4 ', 'null'); -- 0

Insert into stu (name, flag) values ('a5 ', '1'); -- 1

Insert into stu (name, flag) values ('a6 ', null); -- 2

Insert into stu (name, flag) values ('a7 ', '2'); -- 1

Insert into stu (name, flag) values ('a8 ', 15); -- 1

Insert into stu (name, flag) values ('a9 ', "Database"); -- 0

When exporting the database, you can find that the SQL statement executed is like this,

Insert into [stu] values ('a1', 0 );

Insert into [stu] values ('a2 ', 0 );

Insert into [stu] values ('a3 ', 1 );

Insert into [stu] values ('a4 ', 0 );

Insert into [stu] values ('a5 ', 1 );

Insert into [stu] values ('a6 ', null );

Insert into [stu] values ('a7 ', 1 );

Insert into [stu] values ('a8 ', 1 );

Insert into [stu] values ('string', 0 );

Insert into [stu] values ('string2', 0 );

Insert into stu (name, flag) values ('a9 ', 0); -- 0

In this case, we assume that sqlite uses the boolean type data inserted by the stable type storage. However, during the extraction, the inserted string type data is converted to the int type for use.

Therefore, we can draw the following conclusion:

-- The character can be converted to true of the int type, false (0) for conversion failure, integer for int, long double, true (1), Boolean error, null is null

Ps: I have not yet had a deep understanding of it. Currently, it is the conclusion of practical testing. It is purely a guess. If you have any suggestion, please let us know.

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.