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?
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?
You can have a unique composite key:
ALTER TABLE my_table
ADD CONSTRAINT uc_my_table UNIQUE (id, text1, text2)