Re: Can't query the sequence table of a serial primary key. - Mailing list pgsql-admin

From Tom Lane
Subject Re: Can't query the sequence table of a serial primary key.
Date
Msg-id 4387.1330025723@sss.pgh.pa.us
Whole thread Raw
In response to Can't query the sequence table of a serial primary key.  ("Fred Parkinson" <FredP@abag.ca.gov>)
List pgsql-admin
"Fred Parkinson" <FredP@abag.ca.gov> writes:
> We have moved some databases from 7.x to 8.4
> Previously I could query the sequencing table of a 'serial primary key' by simply running
> select * from mytable_id_seq;
> where mytable has id as a serial primary key and mytable_id_seq is the postgresql relation which manages the key.

That naming relationship isn't guaranteed, and AFAIR it wasn't
guaranteed in 7.4 either; in case of name collision you'd get something
like mytable_id_seq1 instead.

> When I do \d I see the table and the sequencer under 'List of relations'.
> But when I run select * from mytable_id_seq; postgresql responds with:
> relation 'mytable_id_seq' does not exist.

Maybe the sequence is in a schema that's not in your search_path.

            regards, tom lane

pgsql-admin by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Can't query the sequence table of a serial primary key.
Next
From: "Fred Parkinson"
Date:
Subject: Re: Can't query the sequence table of a serial primary key.