pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
unique constraints
3+ messages / 2 participants
[nested] [flat]

* unique constraints
@ 2004-01-07 14:17  Kenneth Gonsalves <lawgon@thenilgiris.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Kenneth Gonsalves @ 2004-01-07 14:17 UTC (permalink / raw)
  To: pgsql-sql

in 7.4 i'm getting an error message - UNIQUE constraint matching keys for 
table 'xxx' not found - any clues?
-- 
regards
kg

http://www.ootygolfclub.org
poor man's tally: http://avsap.sourceforge.net



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: unique constraints
@ 2004-01-07 17:31  Michael Fuhr <mike@fuhr.org>
  parent: Kenneth Gonsalves <lawgon@thenilgiris.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Michael Fuhr @ 2004-01-07 17:31 UTC (permalink / raw)
  To: Kenneth Gonsalves <lawgon@thenilgiris.com>; +Cc: pgsql-sql

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/



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: unique constraints
@ 2004-01-08 04:20  Kenneth Gonsalves <lawgon@thenilgiris.com>
  parent: Michael Fuhr <mike@fuhr.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Kenneth Gonsalves @ 2004-01-08 04:20 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-sql

On Wednesday 07 January 2004 23:01, Michael Fuhr wrote:
> 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.
ok, got it now - the key in question was a 'serial' key. in older versions of 
postgres, since serial keys are anyway unique, apparently we could get away 
with not explicitly giving an unique constraint - sigh, a lot of work lies 
ahead ... 
-- 
regards
kg

http://www.ootygolfclub.org
poor man's tally: http://avsap.sourceforge.net



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-01-08 04:20 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-07 14:17 unique constraints Kenneth Gonsalves <lawgon@thenilgiris.com>
2004-01-07 17:31 ` Michael Fuhr <mike@fuhr.org>
2004-01-08 04:20   ` Kenneth Gonsalves <lawgon@thenilgiris.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox