Advertisement
NLinker

Find orphan sequences

Mar 7th, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- find orphan sequences in postgresql
  2. SELECT
  3.   ns.nspname AS SchemaName,
  4.   c.relname  AS SequenceName
  5. FROM pg_class AS c
  6.   JOIN pg_namespace AS ns
  7.     ON c.relnamespace = ns.oid
  8. WHERE c.relkind = 'S'
  9.       AND NOT EXISTS(SELECT *
  10.                      FROM pg_depend
  11.                      WHERE objid = c.oid AND deptype = 'a')
  12. ORDER BY c.relname;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement