Re: [Pgsql-ayuda] problemas con foreign key

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: nuria montoya rodriguez <okeona(at)hotmail(dot)com>
Cc: pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx
Subject: Re: [Pgsql-ayuda] problemas con foreign key
Date: 2004-01-30 23:51:25
Message-ID: 20040130235125.GA26992@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On Fri, Jan 30, 2004 at 06:06:26PM +0000, nuria montoya rodriguez wrote:

> CREATE TABLE table_name(
> ...
> CONSTRAINT constraint_name FOREIGN KEY(campo1,campo2) REFERENCES
> ref_table(ref_campo1,ref_campo2));
> *campo1 y campo2 son las únicas claves primarias de esta tabla.
> *ref_campo1 y ref_campo2 son claves primarias de ref_table, pero hay otra
> más en está tabla(ref_table)
>
> ERROR: UNIQUE constraint matching give keys for referenced table
> "ref_table" not found.

A ver ... el ref_table tienes UNIQUE ref_campo1 y UNIQUE ref_campo2?
Si ese es el caso, no se puede. Lo que necesitas es
UNIQUE (ref_campo1, ref_campo2).

Claro que las otras dos restricciones por separado son mas fuertes que
una sola restriccion para los dos campos, pero ...

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Before you were born your parents weren't as boring as they are now. They
got that way paying your bills, cleaning up your room and listening to you
tell them how idealistic you are." -- Charles J. Sykes' advice to teenagers

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Sergio Arroyo 2004-01-31 00:32:24 Re: [Pgsql-ayuda] problemas con accesos concurrentes
Previous Message Alvaro Herrera 2004-01-30 22:59:47 Re: [Pgsql-ayuda] (no subject)