Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Determine when a tablespace was last copied

The tip is very useful to determine when a tablespace has been loaded or reorged, but not copied.

Here is how to determine which tablespaces have not been copied on the current day and how many days have transpired since the last Full Image Copy. Table names are included for identification pourposes. The tip is very useful to determine when a tablespace has been loaded or reorged, but not copied. It has been tested on DB2 for OS/390 V4 and up.

SELECT A.DBNAME AS DATABASE,                                                 
       A.TSNAME AS TABLESPACE,                                               
       DATE(MAX(TIMESTAMP)) AS DATE_LAST_COPY,                               
       DAYS(CURRENT DATE) - DAYS(DATE(MAX(TIMESTAMP))) AS DAYS_SINCE_COPY,   
       B.NAME AS TABLE_NAME                                                  
FROM SYSIBM.SYSCOPY A , SYSIBM.SYSTABLES B                                   
WHERE A.DBNAME = B.DBNAME                                                    
AND   A.TSNAME = B.TSNAME                                                    
AND   B.TYPE = 'T'                                                           
AND   ICTYPE IN ('F' , 'R' , 'X')                                            
AND   A.DBNAME NOT IN ('DSNDB04','DSNDB07')                                  
GROUP BY A.DBNAME, A.TSNAME , B.NAME                                         
HAVING (DAYS(CURRENT DATE) - DAYS(DATE(MAX(TIMESTAMP)))) > 1                 
ORDER BY 4 DESC , 1, 2              

For More Information

  • Feedback: E-mail the editor with your thoughts about this tip.
  • More tips: Dozens of free DB2 tips and scripts.
  • Tip contest: Have a DB2 tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
  • Ask the Experts: Our SQL, database design, Oracle, SQL Server, DB2, relational model, and data warehousing gurus are waiting to answer your toughest questions.
  • Forums: Ask your technical DB2 questions--or help out your peers by answering them--in our active forums.
  • Best Web Links: DB2 tips, tutorials, and scripts from around the Web.

Dig Deeper on DB2 UDB (universal databases)

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close