Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Check Contraint Question

Re: Check Contraint Question

From: Lyndon Tiu <ltiu_at_alumni.sfu.ca>
Date: Fri, 03 Dec 2004 12:58:26 -0800
Message-ID: <41B0D372.6040803@alumni.sfu.ca>


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-l
Received on Fri Dec 03 2004 - 14:56:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US