View a markdown version of this page

enable_numeric_rounding - Amazon Redshift

Amazon Redshift non supporterà più l'uso delle UDF Python dopo il 30 giugno 2026. Inizieremo ad applicarlo per fasi. Per ulteriori informazioni sulla fine del ciclo di vita e sulle opzioni di migrazione di Python, consulta il post del blog pubblicato il 30 giugno 2025.

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à.

enable_numeric_rounding

Valori (valore predefinito in grassetto)

attivato (true), disattivato (false)

Description

Specifica se utilizzare l'arrotondamento numerico. Se enable_numeric_rounding è on, Amazon Redshift arrotonda i valori NUMERIC quando li trasmette ad altri tipi numerici, come INTEGER o DECIMAL. Se enable_numeric_rounding è off, Amazon Redshift tronca i valori NUMERIC quando li trasmette ad altri tipi numerici. Per ulteriori informazioni sui tipi numerici, consulta Tipi numerici.

Esempio

--Create a table and insert the numeric value 1.5 into it. CREATE TABLE t (a numeric(10, 2)); INSERT INTO t VALUES (1.5); SET enable_numeric_rounding to ON; --Amazon Redshift now rounds NUMERIC values when casting to other numeric types. SELECT a::int FROM t; a --- 2 (1 row) SELECT a::decimal(10, 0) FROM t; a --- 2 (1 row) SELECT a::decimal(10, 5) FROM t; a --------- 1.50000 (1 row) SET enable_numeric_rounding to OFF; --Amazon Redshift now truncates NUMERIC values when casting to other numeric types. SELECT a::int FROM t; a --- 1 (1 row) SELECT a::decimal(10, 0) FROM t; a --- 1 (1 row) SELECT a::decimal(10, 5) FROM t; a --------- 1.50000 (1 row)