Re: PK with an expression in field list

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alejandro Michelin Salomon \( Adinet \)" <alejmsg(at)adinet(dot)com(dot)uy>
Cc: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: PK with an expression in field list
Date: 2006-05-24 19:44:46
Message-ID: 1070.1148499886@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Alejandro Michelin Salomon \( Adinet \)" <alejmsg(at)adinet(dot)com(dot)uy> writes:
> I need create a PK for a table.
> This PK has 3 fields.
> PK is : CONSTRAINT ff_navios PRIMARY KEY ( idempresa, idarmador, UPPER( nome
> ) )
> But seems not work.

You can't define a primary key on an expression. The SQL standard says
so, and even if we wanted to generalize the standard here, we'd have a
bit of a problem with how it'd show up in the information_schema.

You can, however, create a unique index over those values and get pretty
much the same effect.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Ben-Nes 2006-05-24 19:44:59 I dont get it, dump / restore failures to the same cluster.
Previous Message Tom Lane 2006-05-24 19:14:02 Re: meaning of PQresultStatus types