This section is from the "Practical PostgreSQL" book, by John Worsley and Joshua Drake. Also available from Amazon: Practical PostgreSQL.
Binary operators also work on bit strings, as shown in the table below.
Table 4-10. Bit String Operators
| Example | Result |
|---|---|
| B'10001' & B'01101' | 00001 |
| B'10001' | B'01101' | 11101 |
| B'10001' # B'01101' | 11110 |
| ~B'10001' | 01110 |
| B'10001' << 3 | 01000 |
| B'10001' >> 2 | 00100 |
![]() | Shifting Bit Strings |
|---|---|
When shifting bit strings, the original length of the string does not change. Also, when using operators such as &, |, and #, the bit strings within the argument must be of equal length. |
 
Continue to: