Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id E255A79D55 for ; Thu, 12 Jul 2012 02:15:04 -0300 (ADT) Received: from mailout02.ims-firmen.de ([213.174.32.97]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SpBjw-0006Cu-Qb for pgsql-sql@postgresql.org; Thu, 12 Jul 2012 05:15:03 +0000 Received: from mailin02.ims-firmen.de ([192.168.1.142]) by mailout02.ims-firmen.de with esmtp (envelope-from ) id 1SpBjj-0000iH-jV for pgsql-sql@postgresql.org; Thu, 12 Jul 2012 07:14:47 +0200 Received: from [87.170.210.8] (helo=a-kretschmer.de) by mailin02.ims-firmen.de with esmtpsa (TLSv1:AES256-SHA:256) (envelope-from ) id 1SpBji-00041l-6M for pgsql-sql@postgresql.org; Thu, 12 Jul 2012 07:14:47 +0200 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1SpBjh-0001Qu-Qe for pgsql-sql@postgresql.org; Thu, 12 Jul 2012 07:14:45 +0200 Date: Thu, 12 Jul 2012 07:14:45 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: Prevent double entries ... no simple unique index Message-ID: <20120712051445.GA5421@tux> References: <4FFD3050.3010509@gmx.net> <20120711081607.GA17798@tux> <20120711082458.GA19013@tux> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/10 X-Sequence-Number: 36747 Marc Mamin 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°