Re: Howto have a unique restraint on UPPER (textfield) - Mailing list pgsql-sql

From Yeb Havinga
Subject Re: Howto have a unique restraint on UPPER (textfield)
Date
Msg-id 4B6C8626.6080300@gmail.com
Whole thread Raw
In response to Howto have a unique restraint on UPPER (textfield)  (Andreas <maps.on@gmx.net>)
List 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




pgsql-sql by date:

Previous
From: John Lister
Date:
Subject: Partitioning improvements query
Next
From: Louis-David Mitterrand
Date:
Subject: 'image' table with relationships to different objects