X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 89092D1E23B for ; Wed, 7 Jan 2004 17:44:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54191-04 for ; Wed, 7 Jan 2004 13:44:02 -0400 (AST) Received: from quality.qadas.com (quality.qadas.com [204.227.16.4]) by svr1.postgresql.org (Postfix) with ESMTP id E9D8BD1E2C9 for ; Wed, 7 Jan 2004 13:31:47 -0400 (AST) Received: from quality.qadas.com (localhost [127.0.0.1]) by quality.qadas.com (8.12.10/8.12.10) with ESMTP id i07HVlbv025955; Wed, 7 Jan 2004 10:31:47 -0700 (MST) Received: (from mfuhr@localhost) by quality.qadas.com (8.12.10/8.12.10/Submit) id i07HVlZe025953; Wed, 7 Jan 2004 10:31:47 -0700 (MST) Date: Wed, 7 Jan 2004 10:31:47 -0700 From: Michael Fuhr To: Kenneth Gonsalves Cc: pgsql-sql@postgresql.org Subject: Re: unique constraints Message-ID: <20040107103147.A11576@quality.qadas.com> References: <0401071947320T.02497@thenilgiris.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0401071947320T.02497@thenilgiris.com>; from lawgon@thenilgiris.com on Wed, Jan 07, 2004 at 07:47:32PM +0530 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/39 X-Sequence-Number: 16432 On Wed, Jan 07, 2004 at 07:47:32PM +0530, Kenneth Gonsalves wrote: > in 7.4 i'm getting an error message - UNIQUE constraint matching keys for > table 'xxx' not found - any clues? It would be helpful to see the *exact* wording of the error message and the SQL statements that can be used to reproduce the error. I'd guess that you tried to create a foreign key constraint whose referenced column(s) didn't have a UNIQUE constraint: => CREATE TABLE foo (foo_id INTEGER NOT NULL); CREATE TABLE => CREATE TABLE bar (foo_id INTEGER NOT NULL REFERENCES foo (foo_id)); ERROR: there is no unique constraint matching given keys for referenced table "foo" The referenced column(s) should either be a PRIMARY KEY or have a UNIQUE constraint: => CREATE TABLE foo (foo_id INTEGER PRIMARY KEY); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo" CREATE TABLE => CREATE TABLE bar (foo_id INTEGER NOT NULL REFERENCES foo (foo_id)); CREATE TABLE See the "Foreign Keys" documentation for more info: http://www.postgresql.org/docs/current/static/ddl-constraints.html#DDL-CONSTRAINTS-FK -- Michael Fuhr http://www.fuhr.org/~mfuhr/