我是 PostgreSQL 的新手。在数据库中创建表时我有疑问。谁能告诉我 bit
和 boolean
数据类型之间的区别?
最佳答案
bit
只存储数字0
和1
(或null
)。
boolean
仅存储true
和false
(或null
)。数字 (0, 1) 不是 bool 值。 bool 值可以用在任何需要 bool 表达式的地方。所以你可以,例如这样做:
where is_active
需要将一个位列与某物进行比较:
where a_bit_column = 0
(a_bit_column = 0
的结果是一个 bool 值)
与某些 DBMS 的想法相反,表达式 where 0
或 where 1
是不是有效的 bool 表达式。
关于postgresql - PostgreSQL 中 Bit 和 Boolean 数据类型的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46072700/