473,889 Members | 1,679 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 32259
--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...@eart hlink.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_INSTANC E 10

1 record(s) selected.
1 2
----------------- -----------
EXPLAIN_STATEME NT 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
9011
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 every table for a keyword. Is there a way to do that using, an array or next or something. So like, all the table, say tbl_1, tbl_2, tbl_3 etc have let's say 3 columns. id, name, note for example. And I want to seach all 40 tables in the name...
2
1914
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 have one OR two player(s) a team also has a column "level", which may have values "A", "B", or "C" how do you build the "teams" table (the critical question is "do i need to create two fields" for the maximum two possible players?")
3
1741
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 between the reference and the a active schema. I have found one software vendor who has a tool to do this, but it will only do one table at a time (interactively); I have more then 300 and will run this a few times. One other way of determining...
57
25557
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
14183
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 object, in Oracle, we use "desc table" query, in MySQL, we use "describe table" query, in MS Access, we use ???????.
7
1427
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 functions I have to connect to each database and then run \i fn_function_update.sql. I imagined schemas might allow me to globally update functions across a database hosting many schemas with the same structure. In this scenario my webapp would...
3
2614
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
7211
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, but can help explain what I'm looking for. I want the results to be the Row Count from a Table Name out of the Sub-Select. Select Count(*) from
0
2981
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 times and transaction times. These topics are covered by Joe Celko and Richard Snodgrass in their respective books. I have developed a simple schema to test the relevant constraints which are required to keep all the valid times and transaction...
0
9969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10794
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10896
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10443
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7151
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4650
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 we have to send another system
2
4251
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.