如何解决Prisma:创建没有日期的时间戳字段
我想以时间戳记类型在表中创建一个字段,但没有日期戳。 DateTime类型使用日期戳生成该标记,但我不希望这样。谁能帮我吗?
提前谢谢! :)
解决方法
使用时间字段time(stamp) types:
select '2020-09-28 12:22'::timestamp::time;
time
----------
12:22:00
\d ts_test
Table "public.ts_test"
Column | Type | Collation | Nullable | Default
----------+-----------------------------+-----------+----------+---------
ts_tz | timestamp with time zone | | |
ts | timestamp without time zone | | |
ts_txt | character varying | | |
time_fld | time without time zone | | |
insert into ts_test (time_fld) values ('2020-09-28 12:22');
select * from ts_test where time_fld is not null;
ts_tz | ts | ts_txt | time_fld
-------+------+--------+----------
NULL | NULL | NULL | 12:22:00
时间戳将被截断为一个时间。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。