[GENERAL] Getting the column to a which a sequence belongs.

2009-08-27 Thread Thomas Kellerer
Hi, I'm trying to extend the Postgres support in my SQL tool. I'm trying to recreate the SQL for a sequence, and I wonder if there is a way to find out the column to which a sequence belongs. I'm talking either about sequences that are created automatically by PG when using the serial

Re: [GENERAL] Getting the column to a which a sequence belongs.

2009-08-27 Thread Sam Mason
On Thu, Aug 27, 2009 at 09:18:57PM +0200, Thomas Kellerer wrote: I'm trying to extend the Postgres support in my SQL tool. I'm trying to recreate the SQL for a sequence, and I wonder if there is a way to find out the column to which a sequence belongs. The information is all in the system

Re: [GENERAL] Getting the column to a which a sequence belongs.

2009-08-27 Thread Thomas Kellerer
Sam Mason wrote on 27.08.2009 21:51: The information is all in the system catalogs; I've not had much opportunity to fiddle with them so far but the following may be a start to help get things out for you. SELECT c.relname, a.attname, t.relname FROM pg_class c, pg_depend d, pg_class t,