«

»

Aug 18

List unreferenced tables in a DB2 database


--
-- List DB2 base tables which don't have References
--
SELECT sit.TABLE_NAME, 'No References'
FROM SYSIBM.TABLES sit
left outer join syscat.REFERENCES ref1 on ref1.tabschema = sit.TABLE_SCHEMA and ref1.tabname = sit.TABLE_NAME
left outer join syscat.REFERENCES ref2 on ref2.reftabschema = sit.TABLE_SCHEMA and ref2.reftabname = sit.TABLE_NAME
where ref1.constname is null
and ref2.constname is null
and sit.TABLE_SCHEMA = '@MVPADM'
and sit.TABLE_TYPE = 'BASE TABLE';

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>