PostgreSQL 18 reference · String Functions
PostgreSQL TRANSLATE() Function
Replace single characters by position: each character in 'from' becomes the matching character in 'to', or is deleted.
PostgreSQL 18
Syntax
translate(string, from, to)
Parameters
| Parameter | Description |
|---|---|
string |
The input text. |
from |
Characters to replace. |
to |
Replacements, matched by position; missing ones delete. |
Return value
Text.
Examples
SELECT translate('2026-01-05', '-', '.') AS dotted, translate('hello', 'el', 'ip') AS swapped;
Output
dotted | swapped ------------+--------- 2026.01.05 | hippo (1 row)
Run this on your computer — see “Get Started” for setup.
SELECT translate('+1 (555) 010-9999', '+() -', '') AS digits_only;
Output
digits_only ------------- 15550109999 (1 row)
Run this on your computer — see “Get Started” for setup.
Related
REPLACE()· Replace every occurrence of a substring with another string. The search is case-sensitive.REGEXP_REPLACE()· Replace text matching a POSIX regular expression. Add the 'g' flag to replace every match, not just the first.- SQL String Functions · tutorial