PLACING is a reserved keyword defined in the SQL standard and implemented by PostgreSQL and several other databases to build an OVERLAY expression. OVERLAY performs in-place string substitution: it takes a source string, inserts (or overlays) a replacement substring beginning at a specified start position, and optionally for a specified length. The word PLACING separates the source string from the replacement substring, making the syntax self-describing. Unlike the REPLACE function, which substitutes all occurrences, OVERLAY with PLACING modifies the string only at the given position, giving developers precise, index-based control over string editing. Because PLACING is part of the SQL grammar rather than a standalone command, it appears only within the broader OVERLAY expression and cannot be executed by itself.
source_string
(STRING) - The original text to be modified.replacement_string
(STRING) - The text that will be inserted.start_position
(INTEGER) - 1-based character position where replacement starts.length – INTEGER
(optional) - Number of characters to overwrite. If omitted, the replacement inserts without deleting.OVERLAY, SUBSTRING, REPLACE, POSITION, CHARACTER_LENGTH
SQL:1999
PLACING tells the database which substring you intend to insert or overwrite into the source string. It pairs with FROM to define the exact replacement location.
Yes. The keyword is part of the required grammar. Without PLACING the parser cannot distinguish the replacement substring from the source string.
No. PLACING only appears inside the OVERLAY expression. It has no standalone behavior.
You can concatenate SUBSTRING pieces: CONCAT(SUBSTRING(src,1,pos-1), replacement, SUBSTRING(src,pos+len)). That replicates the PLACING effect.