| |
|
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.
|
 |

11-04-09, 10:20
|
|
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
|
|

11-04-09, 10:27
|
|
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
|
|

11-04-09, 10:39
|
|
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.
|
|

11-04-09, 11:04
|
|
Window Washer
|
|
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
|
|
|
|

11-04-09, 11:33
|
|
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.
|
|

11-04-09, 11:42
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
Originally Posted by gqdesi
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
|
|

11-05-09, 23:23
|
|
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.
|

11-06-09, 05:09
|
|
Registered User
|
|
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
|
|
Quote:
Originally Posted by db2dummy1
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
|
|

11-10-09, 22:29
|
|
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.
|
|

11-11-09, 00:11
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
Originally Posted by db2dummy1
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
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|