1

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 ?

1 Answer 1

2

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).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot Laurenz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.