X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 097C89FA395 for ; Sat, 1 Jul 2006 12:48:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 35393-07 for ; Sat, 1 Jul 2006 12:48:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by postgresql.org (Postfix) with ESMTP id 9AD809FA140 for ; Sat, 1 Jul 2006 12:48:12 -0300 (ADT) Received: from lythanhphu ([66.130.229.163]) by VL-MH-MR002.ip.videotron.ca (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTP id <0J1Q006T6EKBA1C0@VL-MH-MR002.ip.videotron.ca> for pgsql-sql@postgresql.org; Sat, 01 Jul 2006 11:48:11 -0400 (EDT) Date: Sat, 01 Jul 2006 11:48:12 -0400 From: Daniel CAUNE Subject: Re: Constraint UNIQUE on a column not case sensitive In-reply-to: <07BE168B-0F4D-417A-8EB4-E1D55F753E19@seespotcode.net> To: 'Michael Glaesemann' , 'Jorge Godoy' Cc: pgsql-sql@postgresql.org Message-id: <0J1Q006T7EKBA1C0@VL-MH-MR002.ip.videotron.ca> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Mailer: Microsoft Office Outlook, Build 11.0.6353 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: quoted-printable Thread-index: AcadFtVLrTmR1qz5QBuJDcwUyfyrVwACiEqw X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/7 X-Sequence-Number: 25581 > -----Message d'origine----- > De : Michael Glaesemann [mailto:grzm@seespotcode.net] > Envoy=C3=A9 : samedi 1 juillet 2006 10:01 > =C3=80 : Daniel CAUNE > Cc : pgsql-sql@postgresql.org > Objet : Re: [SQL] Constraint UNIQUE on a column not case sensitive >=20 >=20 > On Jul 1, 2006, at 22:47 , Daniel CAUNE wrote: >=20 > > The idea is to have an index on that column, in a not case > > sensitive form, i.e. lower(MyColumn). >=20 > I think you're really close. Try >=20 > CREATE UNIQUE INDEX ci_mycolumn_idx ON mytable(lower(mycolumn)); >=20 > Does that do what you're looking for? >=20 > Michael Glaesemann > grzm seespotcode net >=20 >=20 Yes, indeed! I'm stupid! I was searching a constraint form while the = creation of an UNIQUE index makes the job too! The following form is not valid: ALTER TABLE MyTable ADD CONSTRAINT UNQ_MyTable_MyColumn UNIQUE (lower(MyColumn)); But your form makes the expected job: CREATE UNIQUE INDEX IDX_MyTable_MyColumn ON MyTable (lower(MyColumn)); Thanks, -- Daniel CAUNE