改变 Table 添加检查空值和非空值
Alter Table add check for nulls and not nulls
我正在使用 Oracle Express,我想发表一个声明,向我的 Invoices
table 添加一个检查约束,如果 [=如果 Payment_Total > 0
.
,则 13=] 和 Payment_Date
为 NOT NULL
我只知道如何更改 table 以添加检查列值的约束。如果满足特定条件 (ColumnValue > SomeValue),我不明白如何制定允许空值或不允许空值的约束。
以下是表达检查约束的方法:
alter table t add constraint ck_values
check ((payment_date is null and payment_total = 0) or
(payment_date is not null and payment_total > 0)
);
我正在使用 Oracle Express,我想发表一个声明,向我的 Invoices
table 添加一个检查约束,如果 [=如果 Payment_Total > 0
.
Payment_Date
为 NOT NULL
我只知道如何更改 table 以添加检查列值的约束。如果满足特定条件 (ColumnValue > SomeValue),我不明白如何制定允许空值或不允许空值的约束。
以下是表达检查约束的方法:
alter table t add constraint ck_values
check ((payment_date is null and payment_total = 0) or
(payment_date is not null and payment_total > 0)
);