473,508 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get a COUNT(*) for all tables in a schema?

Is there a simple way to get a COUNT(*) for all tables in a schema in
DB2 LUW 9.0?

Jun 27 '08 #1
3 32170
--CELKO-- wrote:
Is there a simple way to get a COUNT(*) for all tables in a schema in
DB2 LUW 9.0?
Well, if the tables are mostly static and you have current statistics
OR your tables are very dynamic and you have sufficiently recent
statistics, selecting from the catalog works great:

select tabname, card from syscat.tables where tabschema =
'<schemaName>'

(noting that for very dynamic table sizes, the exact COUNT(*) isn't
often accurate in any case for long).
Jun 27 '08 #2
ChrisC wrote:
--CELKO-- wrote:
>Is there a simple way to get a COUNT(*) for all tables in a schema in
DB2 LUW 9.0?

Well, if the tables are mostly static and you have current statistics
OR your tables are very dynamic and you have sufficiently recent
statistics, selecting from the catalog works great:

select tabname, card from syscat.tables where tabschema =
'<schemaName>'

(noting that for very dynamic table sizes, the exact COUNT(*) isn't
often accurate in any case for long).
.... otherwise you need to scribble up a stored proc with dynamic SQL
inside..

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 27 '08 #3
On Apr 30, 6:41 pm, --CELKO-- <jcelko...@earthlink.netwrote:
Is there a simple way to get a COUNT(*) for all tables in a schema in
DB2 LUW 9.0?
Depends on what you mean by simple, but it is pretty straightforward
to do it from a shell.

[lelle@53dbd181 Documents]$ for t in `db2 -x "select tabname from
syscat.tables where tabschema = 'LELLE' and type = 'T'"`; do db2
"select '$t', count(1) from lelle.$t"; done

1 2
-- -----------
T1 196608

1 record(s) selected.
1 2
---------------- -----------
EXPLAIN_INSTANCE 10

1 record(s) selected.
1 2
----------------- -----------
EXPLAIN_STATEMENT 20

1 record(s) selected.

[...]

/Lennart
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8991
by: LRW | last post by:
Well, I have another question that's hard to ask, so I may end up over explaining the question. I have about 40 tables, all with a similar column structure. I want to be able to search through...
2
1887
by: Alan Zhong | last post by:
i am a beginner of database design, could anyone please help me to figure out how to make these two tables work. 1) a "players" table, with columns "name", "age" 2) a "teams" table, which can...
3
1725
by: Leo | last post by:
I am trying to determine the changes an application makes to a database. The plan is to copy the existing schema (active) to a reference schema, run the application and then diff the table data...
57
25468
by: Bing Wu | last post by:
Hi all, I am running a database containing large datasets: frames: 20 thousand rows, coordinates: 170 million row. The database has been implemented with: IBM DB2 v8.1
3
14152
by: Atif | last post by:
Hi I am using MS Access 2000 and want to open the Schema to know about Table's structures like column names, data types, primary keys etc. In SQL Server, we use OpenSchema method of Connection...
7
1407
by: Rory Campbell-Lange | last post by:
I have a number of web applications which have a large amount of their logic written in plpgsql. For each particular application I have a separate instance of a database. If I need to update...
3
2593
by: shsandeep | last post by:
What is the query to obtain a list of all the tables having the maximum number of rows in descending order? Cheers, Sandeep.
4
7178
by: Chris | last post by:
Can't seem to figure out how to do this and have been reading for some time now...... I want to select a row count from a table name in SYSTABLES. This statement does not return what I needed,...
0
2956
by: r0cboff | last post by:
Hi there, This is my first time posting in here and I'm hoping somebody can point out where I am going wrong? I am currently trying to use Bitemporal tables. By this I mean a table with a valid...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1570
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.