nls_numeric_characters
从初始化参数派生的数字字符(小数和组分隔符) 。它的默认值,源自nls_territory
初始化参数,初始化参数的默认值nls_territory
取决于操作系统——NLS_LANG
分别源自 Linux/Unix 或 Windows 操作系统上的环境变量或注册表项。
您可以覆盖nls_numeric_characters
初始化参数的默认值,具体取决于您的需要、实例范围、会话范围或语句范围。这是一个简单的例子:
/* current value: , (comma) as decimal separator and
. (period) as group separator and
*/
SQL> show parameter nls_numeric_characters
NAME TYPE VALUE
------------------------------------ ----------- -------------
nls_numeric_characters string ,.
SQL> with t1(col) as(
2 select 1.23 from dual union all
3 select 234.43 from dual
4 )
5 select col
6 from t1;
COL
----------
1,23
234,43
会话范围:
/* set . (period) as decimal separator and
, (comma) as group separator */
SQL> alter session set nls_numeric_characters='.,';
Session altered.
SQL> with t1(col) as(
2 select 1.23 from dual union all
3 select 234.43 from dual
4 )
5 select col
6 from t1;
COL
----------
1.23
234.43
语句范围。在这种情况下,我们必须使用to_char()
函数并提供数字格式模型:
SQL> with t1(col) as(
2 select 1.23 from dual union all
3 select 234.43 from dual
4 )
5 select to_char(col, '990d00', q'[nls_numeric_characters='.,']') as res
6 , col
7 from t1;
RES COL
------- ----------
1.23 1,23
234.43 234,43