Solved

DB2 - Date table was last ALTERed

Posted on 2011-09-08
6
731 Views
Last Modified: 2012-05-12
HI All,

Is there any way on AS400 that I can find out when a table in a schema was last ALTERed. Currently we don't have any mechanism to track table changes in production. ALTER commands are run manually during the implementation of every release. As part of an audit we have been asked to provide a list of all tables that have changed since 2010.

I tried doing a DSPOBJD of all objects in our production schema and then using the "Change Date" column to get the information i need. To my dismay I realized that "Change Date" gets updated every time I run an update on the table data.

Any ideas?

Regards
Ali.
0
Comment
Question by:bhagatali
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:daveslash
ID: 36506355

To my knowledge, the only way to tell if the table was ALTERed would be to look at the journals. An ALTER would record a journal entry of type CH and code F ... probably also an entry of type CG with a code of D.

As you discovered, the "last change date" in DSPFD includes the changes in data, not just structure. Therefore, I think the journals are the only way to detect changes in structure.

HTH,
DaveSlash
0
 
LVL 27

Expert Comment

by:tliotta
ID: 36513291
You might review the "File level identifier" of the tables. This is a kind of timestamp value in the form CYYMMDDHHMMSS that attempts to record the current version level of the file object. Changes to data do not affect the file level, but recreation of the file or ALTER TABLE operations that change structural characteristics will generate new file level IDs.

Note that this value is not the same as a member level ID nor a format level ID.

I'm not sure if there's an easier way to check.

Tom
0
 
LVL 18

Expert Comment

by:daveslash
ID: 36513342

Tom, that's really cool. I never knew that about the file level identifier. That information will definitely come in handy. Thanks!

-- DaveSlash
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:bhagatali
ID: 36513373
Hi Tom,

I had been working all morning today to get that file level identifier extracted. You are right. That field is like a time stamp and gets affected only with an ALTER. Apparently the only easy way to extract that information is using an API. Do you know of any easier method?

There was someone else in my team who found that the the SYSTABLES contains a last modified information too.

select  substr(table_name,1, 20) as TABLE, last_altered_timestamp  
as ALTER_DATE from PRODSCHEMA/systables                                
where date(last_altered_timestamp) >= '2010-10-01'                
and table_type = 'T'                                                    

I am now trying to determine how reliable this information is. Any thoughts on this?

Regards
Ali
0
 
LVL 27

Accepted Solution

by:
tliotta earned 250 total points
ID: 36514306
Good choice for ALTER_DATE from PRODSCHEMA/systables. It might depend on what version your OS is. I suspect that almost anything in version 5 or later should make it reliable, especially if the DB2 group PTF level is reasonably current.

I would run DSPFD to an outfile, selecting a wide subset of physical files. I would include both DDS PFs and SQL tables. Then I would input that file into a simple program that passed each file through the Retrieve Database File Description (QDBRTVFD) API. The file identifier level is right in the header at offset 69 as a CHAR(13) field. I would have the program convert the file ID to a timestamp, and the file name, library and timestamp would all be written into a new table.

That should be easy enough to create. It gives you a good set of test data to start from.

Then I'd run a SQL statement that compared that timestamp for each file against the timestamp from SYSTABLES.

If they all match, then I'd be satisfied with reliability on that system. If they didn't match, I'd attempt to reconcile any mismatches and make my decision based on results.

I haven't had to do the same thing you're doing, so I don't have anything available. But the API will be simple because you won't need to drill into any of its data structures. You only need to retrieve 82 bytes or so for each file you test.

As long as reliability is acceptable, I'd go with ALTER_DATE from the system database catalog. There have been times when DDS PF details weren't recorded the same in the SQL database catalog as SQL tables. I'd just run a basic test to be comfortable. Most recent releases have been pretty good at it.

Tom
0
 
LVL 27

Expert Comment

by:tliotta
ID: 36514326
I never knew that about the file level identifier.

That's used by RSTOBJ when restoring *FILE objects to choose how the restore progresses. When you see things like old copies getting renamed to something like MYFILE0001, it's usually because file IDs don't match.

Unfortunately some times, file ID doesn't work like format ID, so restores don't care if the formats haven't actually changed. It can seem messy to clean up, but there is method behind most of it.

Member IDs can get involved for member restores.

Tom
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Domino Lotusscript Scheduled Agent Tranfer File from AS400 to another 6 127
Fill Field in Displayfile with variable name 7 114
AS400 CPU allocation 3 117
iSeries FTP Exit Program 8 163
Arrow Electronics was searching for a KVM  (Keyboard/Video/Mouse) switch that could display on one single monitor the current status of all units being tested on the rack.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question