Solved

Calculate the size of the tables on DB2

Posted on 2014-02-13
5
4,597 Views
Last Modified: 2014-02-20
Hi,
I've DB2 database on z/OS platform and I need to know how to calculate the total size of the tables for a particular database also the size of a single table.

Can someone tell me the query to calculate this size?

Thanks in advance!
0
Comment
Question by:ralph_rea
[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
  • 2
  • 2
5 Comments
 
LVL 45

Expert Comment

by:Kent Olsen
ID: 39855946
Hi Ralph,

That's more involved than it might first appear.  How well do you know your way around JCL?


Kent
0
 

Author Comment

by:ralph_rea
ID: 39856253
I just want a query to calculate the space used by the tables, for example using the system views sysibm.systables or sysibm.systablespace or other...
0
 
LVL 25

Expert Comment

by:Tomas Helgi Johannsson
ID: 39856756
Hi!

The catalog tables have all of the required info :)
You could query sysibm.systables like this

This is to see the size of a single table

select t.creator schema, t.name tablename, t.dbname database, t.cardf totalrecords, t.spacef totalstorage_in_KB
from sysibm.systables t
where t.name = <mytablename>
and t.creator = <myschemanema>
and t.dname = <mydatabase>

Size of a schema.
select t.creator schema,  sum (IFNULL(t.cardf, 0 )) totalrecords, sum(IFNULL(t.spacef, 0)) totalstorage_in_KB
from sysibm.systables t
group by t.creator

Size of a database.
select t.dbname schema, sum (IFNULL(t.cardf, 0 )) totalrecords, sum(IFNULL(t.spacef, 0)) totalstorage_in_KB
from sysibm.systables t
group by t.dbname

The info in the catalog depends on how often you run your runstats. Make sure you have as current statistics as possible to determine the size.

This is just to give you an idea. For partitioned tables you should join systables and systablepart on dbname and tsname and select the spacef from systablepart tables.
Regards,
    Tomas Helgi
0
 

Author Comment

by:ralph_rea
ID: 39858790
OK, where can I check if the statistics are updated?

There is another way to calculate the size of the tables regardless of the statistics (such as the view DBA_SEGMENTS in oracle?
0
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 500 total points
ID: 39858843
In the same table that is SYSIBM.SYSTABLES, The column for that is statstime.

select t.creator schema, t.name tablename, t.dbname database, t.cardf totalrecords, t.spacef totalstorage_in_KB, t.statstime last_runstat_time
from sysibm.systables t
where t.name = <mytablename>
and t.creator = <myschemanema>
and t.dname = <mydatabase>

Regards,
   Tomas Helgi
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Merging spreadsheets 8 66
changing page verifacation 1 61
Delete old Sharepoint backups 2 21
T-SQL: I need to add an index on a field 5 26
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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