

 Amazon Redshift non supporterà più la creazione di nuovi Python UDFs a partire dalla Patch 198. Python esistente UDFs continuerà a funzionare fino al 30 giugno 2026. Per ulteriori informazioni, consulta il [post del blog](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Funzione REPLACE
<a name="r_REPLACE"></a>

Sostituisce tutte le occorrenze di un insieme di caratteri all'interno di una stringa esistente con altri caratteri specificati. 

REPLACE è simile a [Funzione TRANSLATE](r_TRANSLATE.md) e a [Funzione REGEXP\$1REPLACE](REGEXP_REPLACE.md), ad eccezione del fatto che TRANSLATE esegue più sostituzioni a carattere singolo e REGEXP\$1REPLACE consente di cercare una stringa per un modello di espressione regolare, mentre REPLACE sostituisce un'intera stringa con un'altra stringa.

## Sintassi
<a name="r_REPLACE-synopsis"></a>

```
REPLACE(string, old_chars, new_chars)
```

## Arguments (Argomenti)
<a name="r_REPLACE-arguments"></a>

 *stringa*   
La stringa `CHAR` o `VARCHAR` da cercare in ricerca 

 *old\$1chars*   
La stringa `CHAR` o `VARCHAR` da sostituire. 

 *new\$1chars*   
Nuova stringa `CHAR` o `VARCHAR` che sostituisce *old\$1string*. 

## Tipo restituito
<a name="r_REPLACE-return-type"></a>

VARCHAR  
Se *old\$1chars* o *new\$1chars* è `NULL`, il risultato è `NULL`. 

## Esempi
<a name="r_REPLACE-examples"></a>

Nell'esempio seguente vengono utilizzati i dati della tabella CATEGORY database di esempio TICKIT. Per ulteriori informazioni, consulta [Database di esempio](c_sampledb.md). 

Per convertire la stringa `Shows` in `Theatre` nel campo CATGROUP, utilizza l'esempio seguente. 

```
SELECT catid, catgroup, REPLACE(catgroup, 'Shows', 'Theatre')
FROM category
ORDER BY 1,2,3;

+-------+----------+----------+
| catid | catgroup | replace  |
+-------+----------+----------+
|     1 | Sports   | Sports   |
|     2 | Sports   | Sports   |
|     3 | Sports   | Sports   |
|     4 | Sports   | Sports   |
|     5 | Sports   | Sports   |
|     6 | Shows    | Theatre  |
|     7 | Shows    | Theatre  |
|     8 | Shows    | Theatre  |
|     9 | Concerts | Concerts |
|    10 | Concerts | Concerts |
|    11 | Concerts | Concerts |
+-------+----------+----------+
```