pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRelationship beween sequences (serial) and tables
3+ messages / 3 participants
[nested] [flat]
* Relationship beween sequences (serial) and tables
@ 2005-09-08 08:03 Thusitha Kodikara <kthusi@yahoo.com>
0 siblings, 2 replies; 3+ messages in thread
From: Thusitha Kodikara @ 2005-09-08 08:03 UTC (permalink / raw)
To: pgsql-admin
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Relationship beween sequences (serial) and tables
@ 2005-09-08 12:42 Michael Fuhr <mike@fuhr.org>
parent: Thusitha Kodikara <kthusi@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2005-09-08 12:42 UTC (permalink / raw)
To: Thusitha Kodikara <kthusi@yahoo.com>; +Cc: pgsql-admin
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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Relationship beween sequences (serial) and tables
@ 2005-09-09 17:28 Jim C. Nasby <jnasby@pervasive.com>
parent: Thusitha Kodikara <kthusi@yahoo.com>
1 sibling, 0 replies; 3+ messages in thread
From: Jim C. Nasby @ 2005-09-09 17:28 UTC (permalink / raw)
To: Thusitha Kodikara <kthusi@yahoo.com>; +Cc: pgsql-admin
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-09-09 17:28 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-09-08 08:03 Relationship beween sequences (serial) and tables Thusitha Kodikara <kthusi@yahoo.com>
2005-09-08 12:42 ` Michael Fuhr <mike@fuhr.org>
2005-09-09 17:28 ` Jim C. Nasby <jnasby@pervasive.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox