log() 是一个系统函数,用于返回指定值的以10为底的对数。
log() 添加于 PostgreSQL 6.5。
用法
log (numeric) →numeric
log (double precision) →double precision
提供的值必须大于 0。
请注意,log10() 作为 SQL 标准的等效函数存在,与 log() 相同。
变更历史
- PostgreSQL 6.5
- 添加于 (commit 0e9d75c6)
 
示例
log() 的基本用法示例
postgres=# SELECT log(2);
        log         
--------------------
 0.3010299956639812
(1 row)
无法计算零或负数的对数
postgres=# SELECT log(0); ERROR: cannot take logarithm of zero postgres=# SELECT log(-1); ERROR: cannot take logarithm of a negative number
参考资料
- PostgreSQL 文档: 数学函数
