Skip to content
Advertisement

Unique constrains on different type [closed]

I have two columns like these:

A = {1,2,3}; --> Integer[] Type
B = 3; --> Integer Type

I would like to UNIQUE constrains this 2 columns of different types.

There is a method to compare all the values ​​of an array with single values in postgres?

P.s (A,B) should be unique

Advertisement

Answer

You cannot create a unique constraint on array elements table-wide. You can create a check constraint that will ensure that array elements are unique within that array.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement