表中有两个字段,想要加个约束,条件是:
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: 列检查约束条件无法引用其他列
...全文
2272打赏收藏
这个约束加不了???
表中有两个字段,想要加个约束,条件是: 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: 列检查约束条件无法引用其他列