Re: Can't query the sequence table of a serial primary key.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Fred Parkinson" <FredP(at)abag(dot)ca(dot)gov>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Can't query the sequence table of a serial primary key.
Date: 2012-02-23 19:35:23
Message-ID: 4387.1330025723@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Fred Parkinson" <FredP(at)abag(dot)ca(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Fred Parkinson 2012-02-23 20:22:52 Re: Can't query the sequence table of a serial primary key.
Previous Message Kevin Grittner 2012-02-23 19:34:57 Re: Can't query the sequence table of a serial primary key.