暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL Oracle 兼容性之 - round interval

digoal 2018-04-17
229

作者

digoal

日期

2018-04-17

标签

PostgreSQL , Oracle , interval , 数值 , 转换


背景

Oracle 可以将interval当成一个秒为单位的数值,并允许对其值进行round。

PostgreSQL的round没有写这个,不过我们可以自定义一个兼容函数。

create or replace function round(interval, int) returns float8 as $$ select round(EXTRACT(EPOCH FROM $1)::numeric, $2)::float8; $$ language sql strict immutable;

```
postgres=# select round(interval '1h 10min 1.1second',2);
round


4201.1
(1 row)
```

PostgreSQL大量时间操作函数在这里可以知道到

https://www.postgresql.org/docs/current/static/functions-datetime.html

参考

https://www.postgresql.org/docs/current/static/functions-datetime.html

https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions103.htm

《PostgreSQL Oracle 兼容性 之 NUMTODSINTERVAL》

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

文章转载自digoal,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论