《SQL解惑(第二版)》学习笔记
财政年度表
1 2 3 4 5 6 7 8 9 10 11 12
| CREATE TABLE FiscalYears (fiscal_year INTEGER NOT NULL PRIMARY KEY, start_date DATE NOT NULL, CONSTRAINT valid_start_date CHECK ( (EXTRACT(YEAR FROM start_date) = fiscal_year - 1) AND (EXTRACT(MONTH FROM start_date) = 10) AND (EXTRACT(DAY FROM start_date) = 01) ), end_date DATE NOT NULL, CONSTRAINT valid_end_date CHECK ((EXTRACT(YEAR FROM end_date) = fiscal_year) AND (EXTRACT(MONTH FROM end_date) = 09) AND (EXTRACT(DAY FROM end_date) = 30)));
|
但是……错误的语句竟然成功插入了??
1 2 3 4 5 6 7 8 9 10 11
| mysql> INSERT INTO FiscalYears VALUES -> (1996, '1995-10-01', '1996-08-30'); Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM FiscalYears; + | fiscal_year | start_date | end_date | + | 1996 | 1995-10-01 | 1996-08-30 | + 1 row in set (0.00 sec)
|
bug待解决……
缺勤者
Thank you for your approval.
支付宝
微信支付
WeChat Bezahlung