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 > Profiling Database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-04-09, 10:20
gqdesi gqdesi is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Profiling Database

Hi All,
I tried searching the forums, but couldn't find any results. I'm new to DB2 (mostly work in SQL Server 2005), but I need some help. I would like to profile a database to obtain the following information:
- Table Name
- Column Name
- Data Type
- Number of records
- Number of Values (no NULLS)
- Number of Unique values
- Min Value
- Max Value
- Min Length
- Max Length

I saw that in SYSIBM.SYSCOLUMNS, I can obtain Table Name, Column Name, and Data Type but I was hoping there might be a sys table that holds the other information. If not, how would I create a cursor? I have something that worked in Sybase SQL, but doesn't port over to DB2 syntax.

Thanks in advance for all the help.
- jay
Reply With Quote
  #2 (permalink)  
Old 11-04-09, 10:27
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
name - columns and type can be retrieved from systables - syscolumns
info about the data - only by executing some sql like
select count(*) : nbr of rows
select count(distinct... for unique values....
max(xx) min(xx)
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 11-04-09, 10:39
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Most of this information is available in syscat.columns, sysstat.columns and sysstat.coldist.

But this information is not 'current', but reflects the status of the data when RUNSTATS was last run.

DB2 Information Centre for your version of the product will give description of the columns in each of the above views.

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 11-04-09, 11:04
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Get a catalog poster

DB2 Version 8 Catalog poster courtesy of IBM

Or get ERWin and point it at the database
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #5 (permalink)  
Old 11-04-09, 11:33
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Cheers Brett

@op , the link is for zOS db2 v8. The catalog tables/views do change .. So make sure you are using the right version ... If you are not sure what the column value means, you have to look at the documentation

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #6 (permalink)  
Old 11-04-09, 11:42
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by gqdesi View Post
I saw that in SYSIBM.SYSCOLUMNS, I can obtain Table Name, Column Name, and Data Type but I was hoping there might be a sys table that holds the other information. If not, how would I create a cursor? I have something that worked in Sybase SQL, but doesn't port over to DB2 syntax.

Thanks in advance for all the help.
- jay
If you are using DB2 for LUW, then you should not use the SYSIBM tables. Use the SYSCAT views instead. The are documented in the appendix of SQL Reference Vol 1.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #7 (permalink)  
Old 11-05-09, 23:23
db2dummy1 db2dummy1 is offline
Registered User
 
Join Date: Feb 2009
Posts: 114
Use SYSIBM tables in good health. SYSCAT views are for those who moved to DB2 from "Query Manager", OS/2, Windows, etc. and have not the capacity to remember SYSIBM names. When you grow up and migrate to DB2 on z/OS, you will not find any SYSCAT there. So get ahead of the game and learn SYSIBM names.

P.S. Where is Marcus today? I miss him

Last edited by db2dummy1; 11-05-09 at 23:28.
Reply With Quote
  #8 (permalink)  
Old 11-06-09, 05:09
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by db2dummy1 View Post
Use SYSIBM tables in good health. SYSCAT views are for those who moved to DB2 from "Query Manager", OS/2, Windows, etc. and have not the capacity to remember SYSIBM names. When you grow up and migrate to DB2 on z/OS, you will not find any SYSCAT there. So get ahead of the game and learn SYSIBM names.
The point is that the SYSIBM tables in DB2 LUW are not documented and are not an official interface (except for SYSIBM.SYSDUMMY1). So if you build on that and DB2 changes something in those tables (which can happen at any time, even at run-time as much as the documentation is concerned), it is your fault and not DB2's. Therefore: use the SYSCAT view on DB2 LUW and use the SYSIBM tables on DB2 z/OS. In short: only use APIs that are documented.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #9 (permalink)  
Old 11-10-09, 22:29
gqdesi gqdesi is offline
Registered User
 
Join Date: Nov 2009
Posts: 2
Thanks for all the responses. I'm using DB2 UDB via DBArtisan 8.0.1

What I forgot to mention earlier is that I want to output the counts/max/min in a table.

Ex. ID | TBCreator| TableName | FieldName | DataType | RecordCount| ValueCount | UniqueCount | Max | Min

I created a table that currently has: ID (Auto-number), TBCreator, TableName, FieldName, DataType. I'm assuming that I could run a LOOP statement to cycle through the ID field and perform the necessary counts/max/min on each table/column by concatenating TBCreator and TableName and using that to call the table.
Reply With Quote
  #10 (permalink)  
Old 11-11-09, 00:11
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by db2dummy1 View Post
Use SYSIBM tables in good health. SYSCAT views are for those who moved to DB2 from "Query Manager", OS/2, Windows, etc. and have not the capacity to remember SYSIBM names. When you grow up and migrate to DB2 on z/OS, you will not find any SYSCAT there. So get ahead of the game and learn SYSIBM names.

P.S. Where is Marcus today? I miss him
I am here.

The SYSCAT views are documented as the Catalog Views in the appendix of the SQL Reference Vol 1, whereas the SYSIBM tables are not documented. That alone is sufficient reason why you should use the catalog views instead of tables on DB2 LUW. Obviously, that is not the case for DB2 z/OS, where the SYSIBM tables are documented as the Catalog Tables.

Oh, excuse me! I forgot that you don't read documentation. Never Mind.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
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