scale() 是一个系统函数,它返回参数的小数位数(即小数部分的十进制数字位数)。
scale() 在 PostgreSQL 9.6 中添加。
用法
scale ( numeric ) → integer
从 PostgreSQL 13 开始,提供了 min_scale() 函数,该函数功能相同,但会删除任何尾随的零。
变更历史
- PostgreSQL 9.6
- 添加(提交 abb17339)
示例
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)
参考资料
- PostgreSQL 文档: 数学函数
