Reputation: 31795
Mysql has two types that can hold boolean data, bit and bool. Bit(1) seems more logical, because that has to be 1 or 0, bool is, according to the specs, the same as saying tinyint(1)
Upvotes: 4
Views: 5975
Reputation: 149823
It's also possible to use the CHAR(0)
type. A column that is defined as CHAR(0) NULL
occupies only one bit and can take only the values NULL and '' (the empty string).
This is documented here: http://dev.mysql.com/doc/refman/5.1/en/string-type-overview.html
Upvotes: 1
Reputation: 8851
For keeping things semi-universal / portable across other database vendors, use BIT. MySQL's a step ahead of most servers by even allowing the BOOLEAN keyword.
See: Comparison of different SQL implementations
Upvotes: 5
Reputation: 20878
I think it depends on your application and client library. Some database abstraction layers might expect that a boolean is a type of integer. (I know, technically a bit is an integer)
Upvotes: 1
Reputation: 78324
Au contraire, bool seems much more logical, especially if you want to record truth and falsity.
Upvotes: 5