

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# enable\$1numeric\$1rounding
<a name="r_enable_numeric_rounding"></a>

## 值（默认为粗体）
<a name="r_enable_numeric_rounding-values"></a>

on（true），**off（false）**

## 说明
<a name="r_enable_numeric_rounding-description"></a>

指定是否使用数值四舍五入。如果 `enable_numeric_rounding` 为 `on`，则 Amazon Redshift 在将 NUMERIC 值强制转换为其他数值类型（例如 INTEGER 或 DECIMAL）时会四舍五入。如果 `enable_numeric_rounding` 为 `off`，则 Amazon Redshift 会在将 NUMERIC 值强制转换为其他数值类型时将其截断。有关数值类型的更多信息，请参阅[数字类型](r_Numeric_types201.md)。

## 示例
<a name="r_enable_numeric_rounding-example"></a>

```
--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)
```