【发布时间】:2021-10-25 16:06:17
【问题描述】:
我在应用程序端使用 PostgreSQL 类型 INTERVAL 和 java.time.Period 类型。
我想要的是限制插入除年、月和日之外的所有字段的INTERVAL 列。
我知道INTERVAL type definition 中有[ fields ] 部分,但我只能将YEAR TO MONTH 放入其中:
CREATE TABLE test_interval (
col1 INTERVAL YEAR TO MONTH -- only years and month allowed
)
我需要:
-- not a real SQL
CREATE TABLE test_interval (
col1 INTERVAL YEAR TO MONTH -- only years, month and days allowed
)
有什么解决方法吗?
【问题讨论】:
标签: sql postgresql intervals period