0

I have a table with the following columns: ID, text1, text2.

What to do in order to make (text1,text2) unique, for example: values (1,a,b), (2,b,b), (3,a,a) are allowed, but (4,a,b) will not be inserted because (a,b) is repeating?

user3162968
  • 926
  • 1
  • 8
  • 16

1 Answers1

1

You can have a unique composite key:

ALTER TABLE my_table
ADD CONSTRAINT uc_my_table UNIQUE (id, text1, text2)
Mureinik
  • 277,661
  • 50
  • 283
  • 320