↑↓ select ↵ open ⌫ change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Functions / Binary String Functions And Operators

Extracts n'th bit from binary string.

Reading PG 18current·documented in 25 of 27 versions, 7.3 to 20

Signatures & examples

get_bit ( bytes bytea, n bigint ) → integer
Extracts n'th bit from binary string.
get_bit('\x1234567890'::bytea, 30) → 1
get_bit ( bits bit, n integer ) → integer
Extracts n'th bit from bit string; the first (leftmost) bit is bit 0.
get_bit(B'101010101010101010', 6) → 1
Version history 3
  1. 12 → 13 changed
  2. 8.0 → 8.1 changed
  3. 7.2 → 7.3 added

Definition snapshot: b7bd9cda · English manual source