X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1B744D8642 for ; Fri, 9 Sep 2005 14:28:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43858-10 for ; Fri, 9 Sep 2005 17:28:02 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 12345D8632 for ; Fri, 9 Sep 2005 14:28:02 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 0E6561524F; Fri, 9 Sep 2005 17:28:01 +0000 (GMT) Date: Fri, 9 Sep 2005 12:28:01 -0500 From: "Jim C. Nasby" To: Thusitha Kodikara Cc: pgsql-admin@postgresql.org Subject: Re: Relationship beween sequences (serial) and tables Message-ID: <20050909172801.GG7630@pervasive.com> References: <20050908080327.94284.qmail@web34405.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050908080327.94284.qmail@web34405.mail.mud.yahoo.com> X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] X-Spam-Level: X-Archive-Number: 200509/98 X-Sequence-Number: 18835 On Thu, Sep 08, 2005 at 01:03:26AM -0700, Thusitha Kodikara wrote: > Hi, > > I use Postgres 7.4.5 on Linux > > In many of my tables the primary key is bigserial for which sequences are automatcially generated. Through pg_catalog tables how can I find the relationship petween each table and its corresponding sequence ? If you install newsysviews (http://pgfoundry.org/projects/newsysviews/), the following query will give you all table columns that are using a sequence for their default value: select * from pg_user_table_columns where default_value like 'nextval(%'; -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461