pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Kretschmer <akretschmer@spamfence.net>
To: pgsql-sql@postgresql.org
Subject: Re: Prevent double entries ... no simple unique index
Date: Thu, 12 Jul 2012 07:14:45 +0200
Message-ID: <20120712051445.GA5421@tux> (raw)
In-Reply-To: <C4DAC901169B624F933534A26ED7DF310861B61A@JENMAIL01.ad.intershop.net>
References: <4FFD3050.3010509@gmx.net>
	<20120711081607.GA17798@tux>
	<20120711082458.GA19013@tux>
	<C4DAC901169B624F933534A26ED7DF310861B61A@JENMAIL01.ad.intershop.net>

Marc Mamin <M.Mamin@intershop.de> wrote:

> > 
> > Or this one:
> > 
> > test=*# create unique index on log((case when state = 0 then 0 when
> > state = 1 then 1 else null end));
> > CREATE INDEX
> > 
> > 
> > Now you can insert one '0' and one '1' - value - but no more.
> 
> Hi,
> 
> A partial index would do the same, but requires less space: 
> 
> create unique index on log(state) WHERE state IN (0,1);

Right! ;-)


Andreas
-- 
Really, I'm not out to destroy Microsoft. That will just be a completely
unintentional side effect.                              (Linus Torvalds)
"If I was god, I would recompile penguin with --enable-fly."   (unknown)
Kaufbach, Saxony, Germany, Europe.              N 51.05082°, E 13.56889°



view thread (8+ messages)  latest in thread

Message-ID: <20120712051445.GA5421@tux>
Permalink:  ../20120712051445.GA5421@tux/
Also on:    postgresql.org/message-id/20120712051445.GA5421@tux

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: akretschmer@spamfence.net
  Subject: Re: Prevent double entries ... no simple unique index
  In-Reply-To: <20120712051445.GA5421@tux>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox