All Forums Database
N_Raghu 34 posts Joined 12/13
09 Jul 2014
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?

-Raghu
Raj_k 4 posts Joined 01/14
09 Jul 2014

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 ..

Wait for your time .. You will reach to success ..

dnoeth 4628 posts Joined 11/04
10 Jul 2014

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)
 

Dieter

You must sign in to leave a comment.