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

Count rows of all the tables.


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

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Wed Nov 18, 2009 11:55 am
Reply with quote

Hi All,

I have a question. Is there any system table in DB2 (like SYSTABLES in SYSIBM), where in I can get the count of rows in each table in one particular region. For example there are 3 tables in region XYZ with creator ABC, and I require to know the number of rows in each of three tables without giving a count(*) query for each table.

Thanks,
Muffi
Back to top
View user's profile Send private message
LearningDb2

New User


Joined: 19 Jun 2009
Posts: 40
Location: India

PostPosted: Wed Nov 18, 2009 1:34 pm
Reply with quote

Hi,
You can try real time statistics.
Query the table SYSIBM.SYSTABLESPACESTATS...in which count of rows is mantained..

Else you can try writing a simple procedure selecting table name as variable from SYSIBM.SYSTABLES.
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Wed Nov 18, 2009 2:50 pm
Reply with quote

Try this:

Code:


select sum(card)
          from sysibm.systables
    where creator = 'ABC' ;

Back to top
View user's profile Send private message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Wed Nov 18, 2009 3:52 pm
Reply with quote

bauer,

the query gave me a result -1036.

regards,
Muffi
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Nov 18, 2009 3:58 pm
Reply with quote

I think its CARDF.
Back to top
View user's profile Send private message
rakesh17684

New User


Joined: 08 Oct 2006
Posts: 61
Location: San Diego

PostPosted: Wed Nov 18, 2009 4:38 pm
Reply with quote

just a FYI.. i would be running the query on the SYSIBM tables only if RUNSTATS have been run on the above region and nothing is loaded after that on the same region.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Nov 18, 2009 4:48 pm
Reply with quote

To sum up the previous answers :

It all depends on how accurate it has to be :

If you're happy with whatever was in CARDF at the time of the last runstats , a
select name,cardf from sysibm.systables where creator = 'ABC'
is sufficient.

If you're happy with an value that could be 30 minutes old and possibly completely wrong (when some utility failed or some obscure third party utility ran or a failure in data sharing), a select from sysibm.systablespacestats is OK.
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Thu Nov 19, 2009 1:57 am
Reply with quote

have a look here:

www.ibmmainframes.com/about35155.html
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Thu Nov 19, 2009 10:54 am
Reply with quote

That link directs you to yoururl.com
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: Thu Nov 19, 2009 11:05 am
Reply with quote

Link corrected. . .

Always a good idea to Preview and test a link that is being posted.

d
Back to top
View user's profile Send private message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Thu Nov 19, 2009 12:40 pm
Reply with quote

Hi,

Thanks all for your help. It seems that runstats is necessary to obtain the CARD value from SYSTABLES. In my case the region 'ABC' is a new test region created and I am given a task to load all the tables with the load files given.

Hence runstats is executed on the database the value will not be populated in CARD field.

Thanks,
Muffi
Back to top
View user's profile Send private message
bauer

New User


Joined: 03 Mar 2009
Posts: 28
Location: germany

PostPosted: Thu Nov 19, 2009 1:31 pm
Reply with quote

Ups, sorry for the incorrect link. No idea, why the link was incorrect.
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: Thu Nov 19, 2009 9:03 pm
Reply with quote

Hello,

Quote:
No idea, why the link was incorrect
Because when the URL tag is used, it genereates [url=http://yoururl.com]Type_Description_Here giving the poster the ability to put the url "under" a description. If it is not changed, the link winds up being yoururl.com . . .

If the url itself is shown in the post, it is not necessary to use the url tag (see the previous sentence).

A bit of experimenting with Preview will show this better than i can describe it icon_wink.gif
Back to top
View user's profile Send private message
muffirulz

New User


Joined: 14 Sep 2005
Posts: 74
Location: Atlanta, (USA)

PostPosted: Fri Nov 20, 2009 2:57 pm
Reply with quote

Hi,

Thanks a lot all.. I did a runstats on the database and was able to generate the counts of all the tables in a single go.

Thanks,
Muffi
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 To get the count of rows for every 1 ... DB2 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top