我尝试使用 CURRENT_TIMESTAMP 获取毫秒级的日期时间。
但我只能检索到第二个,如下所示。
我错过了什么吗?
最佳答案
这是一个演示问题。 Postgres 的时间戳确实包括毫秒。 您可以自己格式化时间戳以包含毫秒和/或像这样提取毫秒值:
select to_char(current_timestamp, 'yyyy-mm-dd hh24:mi:ss.us') as ts,
extract (milliseconds from current_timestamp) as ms;
-- result:
-- ts |ms |
-- --------------------------+---------+
-- 2021-07-04 12:23:39.102346|39102.346|
关于postgresql - 为什么我的 PostgreSQL 在 CURRENT_TIMESTAMP 中没有显示毫秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68243218/