↑↓ 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

Sets n'th bit in binary string to newvalue.

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

Signatures & examples

set_bit ( bytes bytea, n bigint, newvalue integer ) → bytea
Sets n'th bit in binary string to newvalue.
set_bit('\x1234567890'::bytea, 30, 0) → \x1234563890
set_bit ( bits bit, n integer, newvalue integer ) → bit
Sets n'th bit in bit string to newvalue; the first (leftmost) bit is bit 0.
set_bit(B'101010101010101010', 6, 0) → 101010001010101010
Version history 2
  1. 12 → 13 changed
  2. 7.2 → 7.3 added

Definition snapshot: b7bd9cda · English manual source