Reputation: 83
I want to place a tuple-constraint over the following code, when fase is 'E', sp must be at least 2
Create table MODULE
(
code varchar2(6),
omschr varchar2(25),
fase varchar2(1) CHECK(fase='P' OR fase='K' OR fase='E'),
docent varchar2(3),
sp number(1),
PRIMARY KEY (code)
);
Upvotes: 1
Views: 2182
Reputation: 50027
Try:
Create table MODULE
(
code varchar2(6),
omschr varchar2(25),
fase varchar2(1),
docent varchar2(3),
sp number(1),
PRIMARY KEY (code),
CHECK(fase='P' OR fase='K' OR (fase='E' and sp >= 2))
);
Share and enjoy.
Upvotes: 2