欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

财政年度表之建表约束

程序员文章站 2022-04-05 10:48:16
...
Create Table FinancialYear
(fiscal_year INTEGER NOT NULL PRIMARY KEY,
start_date DATE NOT NULL,
CHECK ((EXTRACT(YEAR FROM start_date)=fiscal_year-1)
AND (EXTRACT (MONTH FROM start_date)=10)
AND (EXTRACT(DAY FROM start_date)=1),
end_date DATE NOT NULL,
CONSTRAINT valid_end_date
CHECK ((EXTRACT (YEAR FROM end_date)=fiscal_year)
AND (EXTRACT (MONTH FROM end_date)=9)
AND (EXTRACT (DAY FROM end_date)=30)))