sequences and dependences
Hi,
I would like to write a request where I would get the table name and column name of a sequence.
In fact I want the opposite of pg_get_serial_sequence !
I have been looking at the sytem table and could not link the sequence from pg_class to a table (and even less to a table).
And I have not been sucessful looking at the net either !
Cheers,
L@u
The Computing Froggy
__________________________________________________
Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités
http://mail.yahoo.fr Yahoo! Mail
I would like to write a request where I would get the table name and
column name of a sequence.
In fact I want the opposite of pg_get_serial_sequence !
You are looking for refobjid in pg_depend, but this
time the sequence could be a dependent to more than table.
A query like the one bellow is should give you the name of the table,
assuming you account for the correct namespace; it will not automatically
show the name of the column:
select objid::regclass, refobjid::regclass
from pg_depend
where objid::regclass::text = 'person_id_seq' ;
Thanks
Ioannis Tambouras
Import Notes
Reply to msg id not found: 4832E9BA.8000400@viable.netReference msg id not found: 4832E9BA.8000400@viable.net | Resolved by subject fallback
On Fri, 23 May 2008, Laurent ROCHE wrote:
I would like to write a request where I would get the table name and
column name of a sequence. I have been looking at the sytem table and
could not link the sequence from pg_class to a table (and even less to a
table).
There's an example of how to chain between two pg_class entries using
pg_depend that I think is close to what you're looking for at
http://wiki.postgresql.org/wiki/Fixing_Sequences
--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD