From: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
---|---|
To: | "Ed L(dot)" <pgsql(at)bluepolka(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: ERROR: UNIQUE constraint ... not found? |
Date: | 2003-04-02 22:51:15 |
Message-ID: | Pine.LNX.4.21.0304022350030.2573-100000@ponder.fairway2k.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Serial no longer sets a unique index on the field, which I think it did prior
to 7.3. You need to explicitly add one, as primary key I'd guess.
On Wed, 2 Apr 2003, Ed L. wrote:
> Well, I've stared at this little riddle for long enough. Anyone see a
> mistake?
>
> $ cat test.sql
> SELECT version();
>
> CREATE TABLE person (
> id SERIAL,
> name VARCHAR NOT NULL
> );
>
> CREATE TABLE session (
> id SERIAL,
> person_id INTEGER NOT NULL,
> FOREIGN KEY (person_id) REFERENCES person (id)
> );
>
>
>
> $ dropdb drilldb; createdb drilldb; psql -e -d drilldb -f test.sql
> DROP DATABASE
> CREATE DATABASE
> SELECT version();
> version
> ---------------------------------------------------------------------------------------------------------
> PostgreSQL 7.3.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2
> 20020903 (Red Hat Linux 8.0 3.2-7)
> (1 row)
>
> CREATE TABLE person (
> id SERIAL,
> name VARCHAR NOT NULL
> );
> psql:test.sql:6: NOTICE: CREATE TABLE will create implicit sequence
> 'person_id_seq' for SERIAL column 'person.id'
> CREATE TABLE
> CREATE TABLE session (
> id SERIAL,
> person_id INTEGER NOT NULL,
> FOREIGN KEY (person_id) REFERENCES person (id)
> );
> psql:test.sql:12: NOTICE: CREATE TABLE will create implicit sequence
> 'session_id_seq' for SERIAL column 'session.id'
> psql:test.sql:12: NOTICE: CREATE TABLE will create implicit trigger(s) for
> FOREIGN KEY check(s)
> psql:test.sql:12: ERROR: UNIQUE constraint matching given keys for
> referenced table "person" not found
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
--
Nigel J. Andrews
Telephone: +44 (0) 208 941 1136
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2003-04-02 22:56:25 | Re: ERROR: UNIQUE constraint ... not found? |
Previous Message | Dennis Gearon | 2003-04-02 22:46:09 | Re: ERROR: UNIQUE constraint ... not found? |