Search Postgresql Archives

Re: unique index with bool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tmpmac@xxxxxxx wrote:
CREATE UNIQUE INDEX name on table(param1,param2);

How to create such unique index when param2 is bool type, and this
param2 should be accepted only in case of true ?

I tried: CREATE UNIQUE INDEX name on table(param1,(param2 = 'true'));
 but it's not working.

Something like:

CREATE UNIQUE INDEX my_uniq_idx ON table(param1,param2)

ALTER TABLE table ADD CONSTRAINT my_constraint CHECK (param2='' OR param1=true);

So - separate out the test linking param1/param2 from your uniqueness requirement.
--
Richard Huxton
Archonet Ltd


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux