sql - Get biggest tables and check if column exists in these tables (one query) -


i want list biggest tables , check if tables have column logsys.

like:

db2 "select t.tabname,t.npages,(select count(c.colname) syscat.columns c  c.tabname = t.tabname , c.colname = 'logsys') syscat.tables t  t.tabschema = 'own' order t.npages desc fetch first 3 rows only" 
  1. is way? there better way?
  2. the execution running without ending (or end days later... :-( )

the output should show if 1 of these biggest tables, has column named logsys (all tables should list in output of sql statement).

this version might bit more efficient, since there can 1 column specified name in each table:

select   t.tabname,  t.npages,  case     when       exists (select 1               syscat.columns c               c.tabname = t.tabname               , c.tabschema = t.tabschema               , c.colname = 'logsys')      1    else 0  end syscat.tables t     t.tabschema = 'own'  order t.npages desc  fetch first 3 rows 

note both tabname , tabschema needed uniquely identify table.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -