Create unique index or constraint on part of a column

From: Ruben Blanco <rubenblan(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Create unique index or constraint on part of a column
Date: 2011-03-07 23:30:14
Message-ID: AANLkTinhtA7Gy4LrH16aMz=kPevyPXNx8-d355gV=g84@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi:

Is there anyway to create a unique index or constraint on part of a column?

Something like this, but something that works ;-)

ALTER TABLE invoices
ADD CONSTRAINT cons UNIQUE (EXTRACT(YEAR FROM invoice_date),
innvoice_number);

Thanks for any help.
Ruben,

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2011-03-07 23:35:53 Re: Create unique index or constraint on part of a column
Previous Message Merlin Moncure 2011-03-07 22:58:12 Re: Why count(*) doest use index?