Search Postgresql Archives

Re: Create unique index or constraint on part of a column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2011-03-07 at 23:30 +0000, Ruben Blanco wrote:
> 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);

CREATE UNIQUE INDEX invoices_constraint_idx ON invoices
  (EXTRACT(YEAR FROM invoice_date), invoice_number);

Regards,
	Jeff Davis


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux