view table pkey values - Mailing list pgsql-general

From Scott Frankel
Subject view table pkey values
Date
Msg-id 714B692C-6F0B-4EE6-8809-6818ABF1ED38@pacbell.net
Whole thread Raw
Responses Re: view table pkey values
Re: view table pkey values
List pgsql-general
Hello,

Is it possible to select or otherwise view a table's primary key values?


I'm troubleshooting the following error:

    ERROR:  duplicate key value violates unique constraint "foo_pkey"

The insert that yields the error seems innocuous enough:

    INSERT INTO foo (color_id, ordinal, person_id) VALUES (1, 1019, 2);

It seems as if there's a sequence (foo_pkey) that's got some weird
values in it.  The table itself looks like this:


CREATE TABLE foo (
    foo_id    SERIAL        PRIMARY KEY,
    color_id    INTEGER    NOT NULL REFERENCES color(color_id) ON DELETE NO
ACTION,
    ordinal                INTEGER        DEFAULT NULL,
    person_id            INTEGER        NOT NULL REFERENCES person(person_id) ON DELETE
SET NULL ON UPDATE CASCADE,
    created                timestamp    DEFAULT CURRENT_TIMESTAMP);



Thanks in advance,
Scott





pgsql-general by date:

Previous
From: Denis BUCHER
Date:
Subject: Re: Strange "missing tables" problem
Next
From: Raymond O'Donnell
Date:
Subject: Re: view table pkey values