Re: NOTICE: ignoring incomplete trigger group for constraint - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: NOTICE: ignoring incomplete trigger group for constraint
Date
Msg-id 4BF803A3.4020909@iol.ie
Whole thread Raw
In response to Re: NOTICE: ignoring incomplete trigger group for constraint  (erobles <erobles@sensacd.com.mx>)
List pgsql-general
On 22/05/2010 17:03, erobles wrote:

> ERROR: there is no unique constraint matching given keys for referenced
> table "table_name'"
>
>
> there is a way to solve this?? what can i do ??

It means you need to have a primary key, or at least a unique
constraint, on the target table which uses the column(s) which the
foreign key references.

For example:

postgres=# create table a(f1 integer, f2 integer);
CREATE TABLE
postgres=# create table b(f3 integer, f4 integer);
CREATE TABLE
postgres=# alter table a add foreign key (f2) references b(f3);
ERROR:  there is no unique constraint matching given keys for referenced
table "b"

If I now add a primary key to table b, it works:

postgres=# alter table b add primary key(f3);
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index
"b_pkey" for table "b"
ALTER TABLE
postgres=# alter table a add foreign key (f2) references b(f3);
ALTER TABLE


HTH.

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie

pgsql-general by date:

Previous
From: erobles
Date:
Subject: Re: NOTICE: ignoring incomplete trigger group for constraint
Next
From: Merlin Moncure
Date:
Subject: Re: Alter column position