This lesson shows how PostgreSQL substring and overlay functions work step-by-step. Substring extracts a part of a string starting at a given position for a given length. Overlay replaces part of a string starting at a position for a length with a new substring. If the start position is beyond the string length, substring returns an empty string, while overlay appends the new substring at the end. Overlay with length zero inserts the new substring without removing characters. Positions start at 1; if 0 is given, it is treated as 1. The execution table traces these behaviors with examples, and the variable tracker shows how results change after each step. Key moments clarify common confusions about positions and behavior when parameters are out of string bounds.