From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | ASAKALAL(at)bouyguestelecom(dot)fr |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: RE : Foreign key |
Date: | 2005-03-30 16:31:38 |
Message-ID: | 20050330163138.GA35656@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Wed, Mar 30, 2005 at 02:09:05PM +0200, ASAKALAL(at)bouyguestelecom(dot)fr wrote:
>
> Thanks for your answers but i make the modifications, the same error returned.
> Here my script :
> ...
> Create table Salariés (Nom_salarié VARCHAR(20),
> Prénom VARCHAR(20),
> Fonction VARCHAR(50),
> Service VARCHAR(50),
> Adresse VARCHAR(100),
> Numero_SS integer,
> Matricule VARCHAR(6),
> rs_ssii VARCHAR(30) references ssii,
> PRIMARY KEY ( Nom_salarié, rs_ssii)) ;
The salariés table has a primary key with two columns.
> Create table Compteur (id integer,
> Heures_travaillées decimal(6,2),
> Cp_acquis decimal(6,2),
> Cp_pris decimal(6,2),
> RTT_acquis decimal(6,2),
> RTT_pris decimal(6,2),
> Nom_salarié VARCHAR(20) references salariés,
> rs_ssii VARCHAR(30) references ssii,
> PRIMARY KEY ( Nom_salarié,rs_ssii,Id)) ;
The foreign key reference to salariés has only one column but
the primary key for salariés has two columns, hence the error.
It looks like you should be doing this:
Nom_salarié VARCHAR(20),
rs_ssii VARCHAR(30),
FOREIGN KEY (Nom_salarié, rs_ssii) REFERENCES salariés,
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2005-03-30 17:26:39 | Re: RE : Foreign key |
Previous Message | lucas | 2005-03-30 16:17:18 | Re: New record position |