Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group