Re: Check Contraint Question

  • From: Lyndon Tiu <ltiu@xxxxxxxxxxxxx>
  • To: Justis Durkee <justisd@xxxxxxx>
  • Date: Fri, 03 Dec 2004 12:58:26 -0800

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
--
//www.freelists.org/webpage/oracle-l

Other related posts: