先记录一下,后面再补充
clock_timestamp() 和 返回实时时间值的函数, 它们的返回值会在事务中随时间的前进而变化,和 oracle 的sysdate 都是返回实时时间。
pgsql 对 date 和 time 数据类型区分比较明确。
select pg_typeof(clock_timestamp());
-[ RECORD 1 ]-----------------------
pg_typeof | timestamp with time zone
select clock_timestamp(),
clock_timestamp() - interval '10 S',
clock_timestamp() - interval '10 M',
clock_timestamp() - interval '10' HOUR TO MINUTE,
clock_timestamp() - interval '10 H',
clock_timestamp() - interval '10 D',
clock_timestamp() - interval '10 W',
clock_timestamp() - interval '10' YEAR TO MONTH,
clock_timestamp() - interval '10 Y'
-[ RECORD 1 ]---+------------------------------
clock_timestamp | 2017-12-11 18:51:38.300552+08
?column? | 2017-12-11 18:51:28.300555+08
?column? | 2017-12-11 18:41:38.300556+08
?column? | 2017-12-11 18:41:38.300557+08
?column? | 2017-12-11 08:51:38.300558+08
?column? | 2017-12-01 18:51:38.300558+08
?column? | 2017-10-02 18:51:38.300563+08
?column? | 2017-02-11 18:51:38.300564+08
?column? | 2007-12-11 18:51:38.300565+08