«

»

Apr 11

List tables without Primary Keys in a DB2 database


--
-- List DB2 base tables which don't have Primary Keys
--
SELECT sit.TABLE_NAME, 'No Primary Key'
FROM SYSIBM.TABLES sit
LEFT OUTER JOIN SYSIBM.SYSCOLUMNS sic ON sic.TBNAME = sit.TABLE_NAME AND sic.KEYSEQ > 0
WHERE sit.TABLE_SCHEMA = '@MVPADM'
AND sit.TABLE_TYPE = 'BASE TABLE'
AND sic.NAME IS NULL;

1 comment

  1. Janay

    Now I’m like, well duh! Truly thkfnaul for your help.

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>