更新时间:2023-11-29 13:38:16
您需要再次使用魔术词和
p>
You need to use the magic word and
again:
CREATE TABLE students (
....
, CONSTRAINT IC4 CHECK ( classification = 'junior' AND hours >=55 AND hours <= 84 )
我怀疑你会想要其他分类(和使用BETWEEN来定义范围的清晰度)....
I suspect you'll want to have other classifications too, and validate their ranges. Use parentheses and OR to do this. (And use BETWEEN to define the ranges for clarity)....
, CONSTRAINT IC4 CHECK ( ( classification = 'junior' AND hours BETWEEN 55 AND 84 )
OR ( classification = 'sophomore' AND hours BETWEEN 85 AND 124 )
OR ( classification = 'senior' AND hours > 124 )
OR ( classification = 'fresher' )
)
请确保您有一套完整的范围。
Make sure you have a complete set of ranges.