PostgreSQL now()函数没有返回时间

问题描述 投票:0回答:1

在表格中插入now()时,书面值仅包含日期(例如2017-12-20),但不包含documentation中指定的日期和时间。

看到这个SQLfiddle

create table timetest (
    id serial primary key,
    mydate date
);

insert into timetest (mydate) values (
now());

是否有一些特定的命令应该传递给写入或检索时间信息?

postgresql
1个回答
2
投票

您创建了mydate date作为date类型列。 date仅代表日期分数(不出所料)。

如果您需要日期和时间,请使用timestamp类型。

参考文献:

© www.soinside.com 2019 - 2024. All rights reserved.