SQLite Database Boolean-type small test

Source: Internet
Author: User
Tags sqlite sqlite 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), and by the time I practice, a Boolean has three states, 0 (FALSE) 1 (true), and null, as shown in the following illustration,

After the following INSERT statement, the test can be inserted successfully. And, by

SELECT * from stu where flag = "Database"

Query to the line named A9.

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

Exporting the database, you can find that the execution of the SQL statement 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

Thus, it is assumed that the SQLite is a Boolean type of data inserted by a character store, but when taken out, the inserted character data is converted to an int type for use.

Therefore, the following conclusions can be obtained:

--the character can be converted to an int type ture, the conversion fails to False (0), int, long double, and so on ture (1), the Boolean type complains, NULL is NULL

PS: has not yet in-depth understanding of it, is currently the conclusion of practical testing, pure speculation, if the people know, can be informed.

Related Article

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.