赞
踩
参考自:https://www.postgresql.org/docs/10/static/functions-formatting.html
To get three milliseconds, one must write 12.003
, which the conversion treats as 12 + 0.003 = 12.003 seconds.
第一点:众所周知,timestamp数据类型最细粒度到微秒(us),也就是timestamp(6)
那么
- postgres=# create table abc_s.test_lei (c1 timestamp(7));
- WARNING: TIMESTAMP(7) precision reduced to maximum allowed, 6
- 第1行create table abc_s.test_lei (c1 timestamp(7));
- ^
- WARNING: TIMESTAMP(7) precision reduced to maximum allowed, 6
- CREATE TABLE
- postgres=#
- postgres=# \d abc_s.test_lei
- 数据表 "abc_s.test_lei"
- 栏位 | 类型 | Collation | Nullable | Default
- ------+--------------------------------+-----------+----------+---------
- c1 | timestamp(6) without time zone | | |
-
-
- ---->>>>可以看到,自动给变成6了。因为最大到6--微秒
- postgres=#
insert into test_t1 values(to_timestamp('2049-11-22 21:21:21.4','YYYY-MM-DD HH24:MI:SS.MS'));
insert into test_t1 values(to_timestamp('2049-11-22 21:21:21.04','YYYY-MM-DD HH24:MI:SS.MS'));
insert into test_t1 values(to_timestamp('2049-11-22 21:21:21.004','YYYY-MM-DD HH24:MI:SS.MS'));
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。