In a PostgreSQL table I have a column file_bytes
which has the data type bytea.
I am looking for a simple SQL statement to manipulate only the last byte of the content of this column.
In a PostgreSQL table I have a column file_bytes
which has the data type bytea.
I am looking for a simple SQL statement to manipulate only the last byte of the content of this column.
UPDATE test
SET file_bytes = overlay(file_bytes placing 'X'::bytea from octet_length(file_bytes));
https://www.postgresql.org/docs/current/static/functions-binarystring.html
octet_length()
gives the number of bytes of binary data. overlay()
allows to rewrite data from a certain position.