postgres=# postgres=# -- substring(string [from int] [for int]) bytea Extract substring postgres=# select substring('Th\\000omas'::bytea from 2 for 3); substring ----------- h\000o (1 row) postgres=#