Re: multiple PK with a non UNIQUE field - Mailing list pgsql-sql

From davide
Subject Re: multiple PK with a non UNIQUE field
Date
Msg-id 42BF0E0E.9030906@email.it
Whole thread Raw
In response to multiple PK with a non UNIQUE field  (davide <site.webmaster@email.it>)
List pgsql-sql
> if you need a multi column fk don't use the "references" keyword on your create table, instead use the "FOREIGN KEY"

> keyword for the table, see the "create table" help.  
> 
> so for example (untested) change 
> 
>  CREATE TABLE appalto (
>      cod_op         int     not null references Opere,
>      cod_com     int     not null references Opere,
>      scadenza     date     not null,
>      importo        int     not null,   
>      PRIMARY KEY (cod_op,cod_com)
>  );
> 
> to
>  CREATE TABLE appalto (
>      cod_op         int     not null,
>      cod_com     int     not null,
>      scadenza     date     not null,
>      importo        int     not null,   
>      PRIMARY KEY (cod_op,cod_com),
>      FOREIGN KEY (cod_op,cod_com) REFERENCES Opere(cod_op,cod_com)
>  );
> 



In this way it works, thanks.


pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: assorted problems with intarray and other GiST contribs.
Next
From: Markus Bertheau ☭
Date:
Subject: SELECT * FROM foo OFFSET -1 LIMIT 1