Reputation: 680
I have a table which has a column of type bytea. I want to update it and set 76th bit as 1. What query should I use ?
Upvotes: 1
Views: 390
Reputation: 246073
To change the 42nd bit to 1, you could use
UPDATE tab
SET binval = set_bit(binval, 41, 1)
WHERE ...
Note that you may be faster with such operations (but waste space) if you change the column to EXTERNAL
instead of EXTENDED
storage (see the TOAST documentation).
Upvotes: 2