From kthusi@yahoo.com Thu Sep 8 08:03:39 2005 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 23CB5D853B for ; Thu, 8 Sep 2005 05:03:39 -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 16062-08 for ; Thu, 8 Sep 2005 08:03:32 +0000 (GMT) Received: from web34405.mail.mud.yahoo.com (web34405.mail.mud.yahoo.com [66.163.178.154]) by svr1.postgresql.org (Postfix) with SMTP id E2254D82DA for ; Thu, 8 Sep 2005 05:03:30 -0300 (ADT) Received: (qmail 94286 invoked by uid 60001); 8 Sep 2005 08:03:27 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=c1Za6pOPon4bQgSv6lc0ZRZVJzJE+qzq3Po/CwnlL9OhHaUefQ1dIKyzPRA8NSJIA9q3Vnsa2vVbCeqRuYCIkaW+XFg5gUbkwuNenA2RIhyxIc//i/UUMhJqf7XTStPP+SkAfucA0eNBOmDIwF1AMXp6Ko7vLqAUy3jh2l0EDzQ= ; Message-ID: <20050908080327.94284.qmail@web34405.mail.mud.yahoo.com> Received: from [203.115.30.220] by web34405.mail.mud.yahoo.com via HTTP; Thu, 08 Sep 2005 01:03:26 PDT Date: Thu, 8 Sep 2005 01:03:26 -0700 (PDT) From: Thusitha Kodikara Subject: Relationship beween sequences (serial) and tables To: pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-907993953-1126166606=:72792" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.431 required=5 tests=[DNS_FROM_RFC_ABUSE=0.374, HTML_30_40=0.056, HTML_MESSAGE=0.001] X-Spam-Level: X-Archive-Number: 200509/71 X-Sequence-Number: 18808 --0-907993953-1126166606=:72792 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 ? Thanks. -Thusitha --------------------------------- Click here to donate to the Hurricane Katrina relief effort. --0-907993953-1126166606=:72792 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
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 ?
 
Thanks.
 
-Thusitha


Click here to donate to the Hurricane Katrina relief effort. --0-907993953-1126166606=:72792-- From mike@fuhr.org Thu Sep 8 12:42:54 2005 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 5C933D849F for ; Thu, 8 Sep 2005 09:42:54 -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 83019-04 for ; Thu, 8 Sep 2005 12:42:47 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 7848BD8430 for ; Thu, 8 Sep 2005 09:42:48 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j88Cgnjo037499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 Sep 2005 06:42:51 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j88CgmCq068739; Thu, 8 Sep 2005 06:42:48 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j88Cgm12068738; Thu, 8 Sep 2005 06:42:48 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 8 Sep 2005 06:42:48 -0600 From: Michael Fuhr To: Thusitha Kodikara Cc: pgsql-admin@postgresql.org Subject: Re: Relationship beween sequences (serial) and tables Message-ID: <20050908124248.GA68650@winnie.fuhr.org> 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-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/74 X-Sequence-Number: 18811 On Thu, Sep 08, 2005 at 01:03:26AM -0700, Thusitha Kodikara wrote: > 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 ? Depending on what information you're looking for, you might need to query any of the following tables: pg_attrdef pg_attribute pg_class pg_constraint pg_depend pg_index See also "Miscellaneous Functions" ("System Information Functions" in 8.x) in the "Functions and Operators" chapter of the documentation. It can also be useful to run "psql -E" or use "\set ECHO_HIDDEN" in psql to show the SQL queries that psql makes for \d commands. -- Michael Fuhr From jnasby@pervasive.com Fri Sep 9 17:28:14 2005 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