How to use as Functional Index to be used as Primary KEY

Поиск
Список
Период
Сортировка
От Janning Vygen
Тема How to use as Functional Index to be used as Primary KEY
Дата
Msg-id 200407311548.06813.vygen@gmx.de
обсуждение исходный текст
Ответы Re: How to use as Functional Index to be used as Primary KEY  (Peter Eisentraut <peter_e@gmx.net>)
Re: How to use as Functional Index to be used as Primary KEY  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hi,

i searched the docs and the archives and was really wondering that i have not
found anything searching for "functional index primary key".

i would like to have a table of members with nicknames which are
case-insensitive but i would like to save the user given name case-sensitive
to display 'JimKnopf' instead of 'jimknopf':

CREATE TABLE members (
  nickname      text      NOT NULL,
  CONSTRAINT pk_test PRIMARY KEY (lower(name))
);

psql:scratch.sql:7: ERROR:  syntax error at or near "(" at character 92

Of course i can use an index like this:

CREATE TABLE members (
  nickname      text      NOT NULL,
);
CREATE UNIQUE INDEX ix_name ON test (lower(name));

but the key isn't marked as primary then.

So here is my question: How can i define a functional index to be used with a
primary key (using postgreSQL 7.4.3)?

can anybody help me with this problem or give me a link to a archived mail
about this topic?

kind regards,
janning


В списке pgsql-general по дате отправления:

Предыдущее
От: Geoff Caplan
Дата:
Сообщение: Correct escaping of untrusted data
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: How to use as Functional Index to be used as Primary KEY