Arno
Arno

Reputation: 23

How is a boolean saved in a database? Is it a special String?

If you download a Excel file from your Database then "true" or "false" is saved as String. Does it look the same in a Database or are the Booleans converted to Strings for the Excel-Sheet? If the booleans aren't saved as "String" (String with special properties) in a database: How are they saved, as integer (like 0 and 1)?

Upvotes: 1

Views: 1514

Answers (1)

jjonesdesign
jjonesdesign

Reputation: 399

While this is database dependent, I'll provide the best possible answer for an unknown.

In mysql:

Bool, Boolean: These types are synonyms for TINYINT(1). A value of zero is considered false. Non-zero values are considered true.

Otherwise, you can use TINYINT or bit datatype.

TINYINT is support by the vast majority of databases also.

Upvotes: 1

Related Questions