IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Get the size of all tables in a Database


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Richy12

New User


Joined: 29 May 2013
Posts: 22
Location: India

PostPosted: Tue Jun 18, 2013 2:19 pm
Reply with quote

I need to get the rowcount and size(preferably in kB or mB) of all the tables in a Database.

I use DB2 V8.

Can some one help me with this?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 18, 2013 2:35 pm
Reply with quote

Row count you could use COUNT(*)

Size means space utilised by the table data?
Back to top
View user's profile Send private message
Richy12

New User


Joined: 29 May 2013
Posts: 22
Location: India

PostPosted: Tue Jun 18, 2013 2:43 pm
Reply with quote

Yes. The space utilized by the table data and its index.

I am aware of COUNT(*). I presume we would get the size info from some SYSIBM.* tables. So along with that, can we get the row count as well for the all the tables in a database instead of writing individual COUNT(*) queries for the tables.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 18, 2013 4:41 pm
Reply with quote

But first why do you need this?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Tue Jun 18, 2013 4:51 pm
Reply with quote

Hi Richy,

If you have RTS turned on in V8, you can get information from,
For Table Details, check the table SYSIBM.SYSTABLESPACESTATS columns totalrows, datasize

For Index details, check the table sysibm.sysindexspacestats column space.

Otherwise,
From table sysibm.systablespace column Spacef and join with sysibm.systables and column cardf will give you total number of rows.

Remember, DB2 Catalogs are updated with space info only if you have run RUNSTATS utility with UPDATE SPACE option, otherwise it will have -1

Regards,
Sushanth
Back to top
View user's profile Send private message
Richy12

New User


Joined: 29 May 2013
Posts: 22
Location: India

PostPosted: Tue Jun 18, 2013 6:34 pm
Reply with quote

The CARDF and SPACEF values are exponential and seems to be incorrect. Also, for most tables its -1.0000000000000000E+00.

Is there any other way? Can we get this details from the DB* volumes where these table VSAM files reside?


@Pandora - there is a requirement for me to get these details in the test regions. Then we would decide whether or not to free up these tables.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jun 18, 2013 7:25 pm
Reply with quote

Richy,

Did you have a look at the SYSTABLESPACESTATS table as suggested above? IIRC, it used to show the row count instead of having to run a count(*) sql.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 18, 2013 7:33 pm
Reply with quote

Extent information should give them some idea to DBA
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 18, 2013 9:24 pm
Reply with quote

Hello,

I am unsure whether you want space allocated on dasd or the size of the bytes of actual data stored. They are typically different . . .
Back to top
View user's profile Send private message
Richy12

New User


Joined: 29 May 2013
Posts: 22
Location: India

PostPosted: Tue Jun 18, 2013 9:44 pm
Reply with quote

I could not find SYSTABLESPACESTATS and SYSINDEXPACESTATS. May be RTS is turned off.

Arun - can you throw some light on IIRC?

Dick - Yes. I need the total bytes of the actual data stored in the table.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 18, 2013 9:51 pm
Reply with quote

Quote:
IIRC means If I remember correctly icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 18, 2013 10:15 pm
Reply with quote

Hello,

Quote:
Yes. I need the total bytes of the actual data stored in the table.
I'm not aware of how to get this automagically . . .

One way would be to "extract" the table(s) in text format and determine the number of bytes unloaded ? If there were not too many tables . . .
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Jun 19, 2013 10:13 am
Reply with quote

Hi Richy12,

If Runstats have not been, getting the total number of rows would be tedious.

Next set of options would be for getting the space information is,
* If you know the naming conventions of underlying DB2 datasets, you can do a listcat for ALL the tablespaces(too much work) OR write a rexx to do that.
* Best idea would be to contact the storage and give them the naming convention of the DB2 datasets and you will get the space information.

Regards,
Sushanth
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Jun 19, 2013 6:48 pm
Reply with quote

Hi Susanth,

If i understand the question, what is wanted is the number of bytes used rather than allocated . . .

As rows with VarChar columns are not always the same length, even row count might not be enough for what is wanted.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts What database does Jobtrac use CA Products 4
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top