DB2 Scripts – Table Management

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Here are a few more nice DB2 scripts that would save you time:

Get all tables in Table Space

-- Get all tables in particular tablespace
select SUBSTR(TABNAME,1,25) "TABNAME", SUBSTR(TABSCHEMA,1,15) "SCHEMA", NPAGES, CARD
from syscat.tables where tbspace = '?'

Generate Grants for all tables in Table Space

-- Genereating GRANTS 
SELECT 'grant select on ' || tabname || ' to PSFDEV' || ';'
FROM syscat.tables
WHERE tabname NOT IN (SELECT tabname
FROM syscat.tabauth
WHERE grantee = 'PSFDEV')
AND tabschema = 'PSFSSYS'
AND (type = 'T' OR type = 'V')

I really want to know what you think