Bit String Functions and Operators

Reference: Bit String Functions and Operators

Bit String Functions and Operators allow to examine and manipulate bit strings. The supported data types are bit and bit varying.

ℹ️
Bitstring functions ignore null values and return null when one input is null.

See PostgreSQL: Bit string functions and operators for the PostgreSQL documentation.

General-purpose functions

bit & bit

Bitwise AND (inputs must be of equal length). Example:

SELECT B'10011' & B'10101'; -> B'10001'

bit | bit

Bitwise OR (inputs must be of equal length). Example:

SELECT B'10011' | B'10101'; -> B'10111'

bit # bit

Bitwise XOR (inputs must be of equal length). Example:

SELECT B'10011' # B'10101'; -> B'00110'