PostgreSQL OVERLAY
From w3cyberlearnings
Contents |
Postgresql overlay
Replace a substring.
Syntax overlay
- string1 is a main string
- string2 is the substring to replace
- start1 is the start index
- length2 is the length to be replaced.
overlay(string1 placing string2 from start1 for length2);
Example 1
test2=# SELECT overlay('Gxxxt' placing 'rea' from 2 for 3); overlay --------- Great (1 row)
Example 2
test2=# SELECT user_firstname, test2-# overlay(user_firstname placing 'a' from 2 for 1) as new_firstname test2-# FROM profile; user_firstname | new_firstname ----------------+--------------- Jim | Jam king | kang Jammi | Jammi Bob | Bab | (5 rows)