Re: Howto have a unique restraint on UPPER (textfield)

From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: Andreas <maps(dot)on(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Howto have a unique restraint on UPPER (textfield)
Date: 2010-02-05 20:57:10
Message-ID: 4B6C8626.6080300@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andreas wrote:
> is there a way to define a unique restraint on UPPER (textfield)?
> psql throws a syntax error because of the upper() function.
The third section of the create index command at
http://www.postgresql.org/docs/8.4/interactive/sql-createindex.html
describes a function based index with as example the function ....
upper! :-)

postgres=# create table aap (a text);
CREATE TABLE
postgres=# create unique index ai on aap (upper(a));
CREATE INDEX
postgres=# insert into aap values ('aap');
INSERT 0 1
postgres=# insert into aap values ('aaP');
ERROR: duplicate key value violates unique constraint "ai"

regards,
Yeb Havinga

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2010-02-09 07:49:09 'image' table with relationships to different objects
Previous Message John Lister 2010-02-04 21:59:37 Partitioning improvements query