Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Check Contraint Question
Justis Durkee wrote:
> One way to accomplish this requirement is to create a unique index on
> column1 and column2, so column1 will only be indexed if column 2 = 1.
>
> SQL> create table t(
> 2 column1 varchar2(32),
> 3 column2 number constraint check_column2 check( column2 in (0,1) )
> 4 );
>
> Table created.
>
> SQL> create unique index t_unique on t( decode( column2, 1, column1,
> null ) );
This does it, thank you very much.
-- Lyndon Tiu -- http://www.freelists.org/webpage/oracle-lReceived on Fri Dec 03 2004 - 14:56:05 CST
![]() |
![]() |