SQLite 3 reference · String Functions
SQLite REPLACE() Function
Replace every occurrence of one string with another inside a string. The search is case-sensitive.
SQLite 3
Syntax
replace(X, Y, Z)
Parameters
| Parameter | Description |
|---|---|
X |
The original string. |
Y |
The text to find. |
Z |
The replacement. |
Return value
The new string.
Examples
SELECT replace('2026-01-05', '-', '/') AS us_style,
replace('tea and cake', 'and', '&') AS short;
Output
us_style | short 2026/01/05 | tea & cake
SELECT name, replace(lower(name), ' ', '-') AS slug
FROM products
LIMIT 3;
Output
name | slug SQL for Beginners | sql-for-beginners Clean Code | clean-code The Pragmatic Programmer | the-pragmatic-programmer
In other languages
REPLACE()· PostgreSQL
Related
SUBSTR()· Return part of a string starting at a 1-based position, with an optional length. Negative starts count from the end.TRIM()· Remove spaces, or any characters you list, from both ends of a string. Spaces inside the string are kept.- SQL String Functions · tutorial