Constraints in Teradata


Constraints in Teradata

Can we create unique constraint on a partial column?

For example:

If I have 2 columns in a table with Col1 and Col2. Can I define a constraint on Col1 saying....values of Col1 should be unique only when Col2>1. When Col2<1 it should allow non unique values in Col1.

Is this possible?


Re: Constraints in Teradata

I don't know exactly ,

First of all if you declare constraint naming UNIQUE means then how it will accept non unique values .. likewise you have mentioned another one Constraint CHECK .. samething if the check also not satisfiesfied means it wont insert ..

Col1 int not null unique,

Col2 int not null (co12 > 1 and col2 < some value)

If the column1 accepts the non-unique values means We cannot say it as unique Constraint ..

Senior Apprentice

Re: Constraints in Teradata

Hi Raghu,

you can't do that with a constraint in Teradata.

Should be done during load (or in a trigger, but performance might be horrible)