PostgreSQL 9.4.1 Documentation | |||
---|---|---|---|
Prev | Up | Chapter 9. Functions and Operators | Next |
9.6. Bit String Functions and Operators
This section describes functions and operators for examining and manipulating bit strings, that is values of the typesbit andbit varying. Aside from the usual comparison operators, the operators shown inTable 9-11 can be used. Bit string operands of&,|, and# must be of equal length. When bit shifting, the original length of the string is preserved, as shown in the examples.
Table 9-11. Bit String Operators
Operator | Description | Example | Result |
---|---|---|---|
|| | concatenation | B'10001' || B'011' | 10001011 |
& | bitwise AND | B'10001' & B'01101' | 00001 |
| | bitwise OR | B'10001' | B'01101' | 11101 |
# | bitwise XOR | B'10001' # B'01101' | 11100 |
~ | bitwise NOT | ~ B'10001' | 01110 |
<< | bitwise shift left | B'10001' << 3 | 01000 |
>> | bitwise shift right | B'10001' >> 2 | 00100 |