Search Postgresql Archives

Re: NOTICE: ignoring incomplete trigger group for constraint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux