SQL-CONSTRAINT

问题描述 投票:2回答:1

是否可以创建一个根据其他列值自动更新列值的表?

例如,我需要创建一个GRADES表:

GRADES-> STUDENT_ID GRADE1 GRADE2 GRADE3 FINAL_GRADE

我希望最终成绩的值等于不为空的最后一个成绩。例如,>

(studentid = 12345 grade1 = null grade2 = null grade3 = null finalgrade =null)
(studentid = 12345 grade1 = 80 grade2 = null grade3 = null finalgrade =80)
(studentid = 12345 grade1 = 80 grade2 = 75 grade3 = null finalgrade =75)
(studentid = 12345 grade1 = 80 grade2 = 75 grade3 = 90 finalgrade =90)

是否可以创建一个表,该表根据另一个列的值自动更新一个列的值?例如,我需要创建一个GRADES表:GRADES-> STUDENT_ID GRADE1 ...

sql oracle constraints
1个回答
4
投票

是,有一个叫virtual column的东西:

© www.soinside.com 2019 - 2024. All rights reserved.