Suppose I have 3 columns in a table - A, B and C. I want to make sure that if I insert any value (say x) into column A, I cannot insert a tuple with B or C equal to x, those. x must remain unique for column A for all tuples.
Note that x can be repeated in for some other tuple.
I know the UNIQUE clause in SQL, but this is only to ensure that the value occurs in a specific column only once. Since Oracle's CHECK statements do not allow subqueries, I cannot figure out how to implement this.
EDIT (to add additional information)
The primary key is Employee_Number, and 3 columns are LandlineNo, MobileNo, and VOIP. Thus, suppose this was a single entry:
Employee_Number = 1, LandlineNo = x, MobileNo = y, VOIP = z
Then this entry for another tuple is NOT allowed -
Employee_Number = 2, LandlineNo = a, MobileNo = x, VOIP = c
On the other hand, it will be good (yes, 2 employees can have the same amount of the same type)
Employee_Number = 2, LandlineNo = x, MobileNo = b, VOIP = c
sql oracle tuples multiple-columns unique-constraint
Noble six taniguchi
source share