Re: multiple PK with a non UNIQUE field

From: davide <site(dot)webmaster(at)email(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: multiple PK with a non UNIQUE field
Date: 2005-06-26 20:20:30
Message-ID: 42BF0E0E.9030906@email.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2005-06-27 04:08:15 Re: [SQL] ARRAY() returning NULL instead of ARRAY[]
Previous Message Michael Fuhr 2005-06-26 18:25:40 Re: assorted problems with intarray and other GiST contribs.