Home > database >  This constraint and???????
This constraint and???????

Time:12-10

There are two fields in the table, want to add a constraint, the condition is:
1, the field can be null, when a null, there is no requirement
2, when the field is a non-empty, required field must not empty b

Add constraint statement:
 alter table shpfront add constraint 
Check (
Shop_id is null
Or (
Shop_id is not null and duty_id is not null
)
);


An error
ORA - 02438: column check constraints can't quote the other columns

CodePudding user response:

 
The alter table shpfront add constraint aaa
Check (
Shop_id is null
Or (
Shop_id is not null and duty_id is not null
)
);

CodePudding user response:

Use the insert row trigger to solve this kind of complex requirements,
  • Related