If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > alter tables list

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-26-10, 09:08
arun-dba arun-dba is offline
Registered User
 
Join Date: Jan 2009
Posts: 8
alter tables list

hi ALL

is it possible to get the list of tables that has altered using "ALTER TABLE" command.
Reply With Quote
  #2 (permalink)  
Old 04-26-10, 13:02
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You can select all tables from the DB2 catalog where the create-timestamp differs from the alter timestamp. Have a look at SYSCAT.TABLES and columns CREATE_TIME and ALTER_TIME. On DB2 z/OS, you would use SYSIBM.SYSTABLES and columns CREATEDTS and ALTEREDTS.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 04-26-10, 13:03
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Quote:
Originally Posted by arun-dba View Post
hi ALL

is it possible to get the list of tables that has altered using "ALTER TABLE" command.
probably db2look -d db_name -e -o outfile
and then look for ALTER in the outfile.sql
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 04-27-10, 14:57
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Markham

Alter table statements are not produced with db2look. Only exception is for creation of a PK.

Once you alter table to add a col or change data type it becomes part of its ddl and future db2look attempts will show this change as part of a regular ddl.

Knut,

That is only for 9.5 and above. Correct?
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #5 (permalink)  
Old 04-27-10, 15:29
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Quote:
Originally Posted by Cougar8000 View Post
Markham

Alter table statements are not produced with db2look. Only exception is for creation of a PK.

Once you alter table to add a col or change data type it becomes part of its ddl and future db2look attempts will show this change as part of a regular ddl.

Knut,

That is only for 9.5 and above. Correct?

i stand corrected.

though i see
ALTER TABLE "DBA "."tab_name" PCTFREE 10;
statements in db2look output.
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #6 (permalink)  
Old 04-27-10, 15:36
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
right, but you wont see any structural changes.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #7 (permalink)  
Old 04-28-10, 08:27
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
Quote:
Originally Posted by Cougar8000 View Post
right, but you wont see any structural changes.
you are absolutely right
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #8 (permalink)  
Old 04-28-10, 10:10
arun-dba arun-dba is offline
Registered User
 
Join Date: Jan 2009
Posts: 8
Thumbs up

thanks Stolze.

i got is from syscat.tables and column name ALTER_TIME.
Reply With Quote
  #9 (permalink)  
Old 04-28-10, 17:03
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by Cougar8000 View Post
That is only for 9.5 and above. Correct?
No, the timestamps to track the last table alteration are available in DB2 for a long time already. Such information is needed, for example, to rebind packages in case a table has changed.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #10 (permalink)  
Old 04-29-10, 09:34
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
I am not seeing it in 9.1 nor in 9.1 manuals. Do I have a stolen version or it is in another place?
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #11 (permalink)  
Old 04-29-10, 16:46
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Looks like it alter_time was added in v9.5


From v9.1:

$ db2 "describe select * from sysibm.systables" | grep -i time
392 TIMESTAMP 26 CTIME 5 0 SYSIBM .TIMESTAMP 18
393 TIMESTAMP 26 STATS_TIME 10 0 SYSIBM .TIMESTAMP 18
393 TIMESTAMP 26 REFRESH_TIME 12 0 SYSIBM .TIMESTAMP 18
393 TIMESTAMP 26 LAST_REGEN_TIME 15 0 SYSIBM .TIMESTAMP 18
392 TIMESTAMP 26 INVALIDATE_TIME 15 0 SYSIBM .TIMESTAMP 18



From v9.5:

$ db2 "describe select * from sysibm.systables" | grep -i time
392 TIMESTAMP 26 CTIME 5 0 SYSIBM 6 TIMESTAMP 9
393 TIMESTAMP 26 STATS_TIME 10 0 SYSIBM 6 TIMESTAMP 9
393 TIMESTAMP 26 REFRESH_TIME 12 0 SYSIBM 6 TIMESTAMP 9
393 TIMESTAMP 26 LAST_REGEN_TIME 15 0 SYSIBM 6 TIMESTAMP 9
392 TIMESTAMP 26 INVALIDATE_TIME 15 0 SYSIBM 6 TIMESTAMP 9
392 TIMESTAMP 26 ALTER_TIME 10 0 SYSIBM 6 TIMESTAMP 9
Reply With Quote
  #12 (permalink)  
Old 04-30-10, 09:32
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I stand corrected. The ALTER_TIME attribute was indeed added in V9.5 (ftp://ftp.software.ibm.com/ps/produc.../db2mgg952.pdf). I would have thought that it came with the ALTER VIEW statement in V9.1 already.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On