我得到了2個表,Persons
和Relationships
。2個表之間的Oracle SQL Check約束
Persons
表只有2個字段:ID
和Age
。
Relationships
有3個領域:Person_ID
,Relative_ID
和Relation
我想要做的是簡單的:在插入\更新Relationships
我要檢查以下內容:
if Relation == 'child' and Persons[Person_ID].Age < Persons[Relative_ID].Age:
Throw Exception
感謝
到目前爲止你做了什麼? –
我解決了其他問題,我有:我也有一個「工作類」字段,我想成爲10個可能的值之一,所以我創建了一個「Workclasses」表,並創建一個外鍵約束從persons_workclass字段到workclasses_name字段。 –