表中有兩個欄位,想要加個約束,條件是:
1、欄位 a 可以為空,當 a 為空時,沒有要求
2、當欄位 a 非空時,要求欄位 b 也必須非空
加約束的陳述句:
alter table shpfront add constraint
check (
shop_id is null
or (
shop_id is not null and duty_id is not null
)
);
報錯
ORA-02438: 列檢查約束條件無法參考其他列
uj5u.com熱心網友回復:
alter table shpfront add constraint aaa
check (
shop_id is null
or (
shop_id is not null and duty_id is not null
)
);
uj5u.com熱心網友回復:
使用插入行觸發器來解決這種復雜需求 。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/232155.html
標籤:基礎和管理
