scale()

返回参数小数位数的函数

scale() 是一个系统函数,它返回参数的小数位数(即小数部分的十进制数字位数)。

scale()PostgreSQL 9.6 中添加。

用法

scale ( numeric ) → integer

PostgreSQL 13 开始,提供了 min_scale() 函数,该函数功能相同,但会删除任何尾随的零。

变更历史

示例

scale() 的执行示例

postgres=# SELECT scale(1.2300);
 scale
-------
     4
(1 row)

postgres=# SELECT scale(1.23);
 scale
-------
     2
(1 row)

postgres=# SELECT scale(1.0);
 scale
-------
     1
(1 row)

postgres=# SELECT scale(1);
 scale
-------
     0
(1 row)

分类

系统函数

另请参阅

min_scale(), trim_scale()

反馈

对于 "scale()",请在此处 提交任何评论、建议或更正