Created
August 19, 2010 18:17
-
-
Save adamfast/538530 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I needed to find info on a sequence that was causing problems with one of our apps, and couldn't find any info online. Here's what I ended up doing. | |
\d <sequence> wasn't telling me anything except that it did exist. I couldn't find out what was using it in order to determine if it was safe to eliminate. | |
select oid from pg_class where relname='<sequence>'; # retrieves the internal ID in PostgreSQL | |
select refobjid from pg_depend where objid = <found_oid>; # retrieve depenencies for the sequence in question. | |
select relname from pg_class where oid in (<ref_oid1>, # ... if others); # get the names that are linking to it | |
\d <found_tables> for each item found above - see if there's any mention of the index blowing up. | |
OR, after figuring this out, I kept working. Here's one query to rule them all: | |
select relname from pg_class where oid in (select refobjid from pg_depend where objid in (select oid from pg_class where relname='<sequence>')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment