---
title: "SUSTITUIR"
description: "La funci\u00F3n SQL REPLACE cambia un texto dado reemplazando todas las apariciones de una lista ordenada de textos por sus textos de reemplazo asociados."
language: es
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/es/docs/invantive-universalsql/grammar/sql-functions/replace
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/replace
updated: 2026-12-02T12:10:43Z
license: https://documentation.invantive.eu/es/
---

## Sintaxis
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> REPLACE[REPLACE]:::quoted
    REPLACE --> End((END))
```

## Propósito
La función SQL `REPLACE` modifica un texto dado sustituyendo todas las apariciones de una lista ordenada de textos por los textos de sustitución asociados a cada uno de ellos.

Véanse también [[TRANSLATE]] y [[REGEXP_REPLACE]].

Parámetros:
- Entrada (`varchar2`): el texto que se quiere modificar.
- Texto antiguo 1 (`varchar2`): el texto que se va a sustituir.
- Nuevo texto 1 (`varchar2`): el texto de sustitución.
- Texto antiguo n (opcional, `varchar2`): textos adicionales que deben sustituirse.
- Nuevo texto n (opcional, `varchar2`): textos de sustitución adicionales.

Resultados: Un texto en el que todos los textos antiguos se sustituyen por sus nuevas versiones, en el orden en que aparecen en la lista.

## Ejemplos
En el siguiente ejemplo se sustituye `b` por `z` en `abc`:
```sql
select replace('abc', 'b', 'z')

-------------------
azc
```
En el siguiente ejemplo se elimina `b` de `abc` sustituyéndolo por un texto vacío, y se sustituye `c` por `d`:
```sql
select replace('abc', 'b', '', 'c', 'd')

-------------------
ad
```
En el siguiente ejemplo, la entrada no sufre ningún cambio, ya que el texto original es `null`:
```sql
select replace('abcd', null, 'z')

-------------------
abcd
```

