select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / STRING FUNCTIONS AND OPERATORS

Replaces the substring of string that starts at the start'th character and extends for count characters with newsubstring.

Signatures & examples

overlay ( string text PLACING newsubstring text FROM start integer [ FOR count integer ] ) → text
Replaces the substring of string that starts at the start'th character and extends for count characters with newsubstring. If count is omitted, it defaults to the length of newsubstring.
overlay('Txxxxas' placing 'hom' from 2 for 4) → Thomas
overlay ( bytes bytea PLACING newsubstring bytea FROM start integer [ FOR count integer ] ) → bytea
Replaces the substring of bytes that starts at the start'th byte and extends for count bytes with newsubstring. If count is omitted, it defaults to the length of newsubstring.
overlay('\x1234567890'::bytea placing '\002\003'::bytea from 2 for 3) → \x12020390
overlay ( bits bit PLACING newsubstring bit FROM start integer [ FOR count integer ] ) → bit
Replaces the substring of bits that starts at the start'th bit and extends for count bits with newsubstring. If count is omitted, it defaults to the length of newsubstring.
overlay(B'01010101010101010' placing B'11111' from 2 for 3) → 0111110101010101010
Version history 1
  1. PG 12 → 13changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source