primary key on lower(varchar)

From: <me(at)alternize(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: primary key on lower(varchar)
Date: 2006-01-07 00:28:07
Message-ID: 0cfb01c61321$3b6d86c0$0201a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hi list

why can't i define a primary key on a varchar field as being lower(field)?

i'm getting the following error:

ERROR: syntax error at or near "(" at character 94: PRIMARY KEY ((lower(e_name) ));

here's the sql script:

ALTER TABLE "oldtables"."lexikon_entries"
DROP CONSTRAINT "lexikon_entries_pkey" RESTRICT;

ALTER TABLE "oldtables"."lexikon_entries"
ADD CONSTRAINT "lexikon_entries_pkey"
PRIMARY KEY ((lower(e_name) ));

ALTER INDEX "oldtables"."lexikon_entries_pkey"
OWNER TO "db_outnow";

this seems to work for normal indices... do i really have to create a 2nd index on the same field?

- thomas

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2006-01-07 02:26:51 Re: SQL Question
Previous Message operationsengineer1 2006-01-07 00:02:53 SQL Question