You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Knex.js创建带时区的time类型列?

在Knex.js ^2.3.0中创建PostgreSQL的time with timezone类型列

Knex.js的table.time()方法在PostgreSQL环境下默认生成time without timezone类型的列,要创建time with time zone类型的列,可以通过以下方式实现:

  • 使用specificType()方法直接指定PostgreSQL的目标类型:
table.specificType('timeColumnWithTimezone', 'time with time zone');

该方法会直接生成对应的DDL语句,创建带时区的时间类型列,完全满足需求。

内容的提问来源于stack exchange,提问作者Pramuditha Chamikara

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 12:15:41