473,394 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

List of tables having maximum number of rows

What is the query to obtain a list of all the tables having the maximum
number of rows in descending order?

Cheers,
Sandeep.

May 15 '06 #1
3 2591
"shsandeep" <sa**********@gmail.com> wrote in message
news:c7******************************@localhost.ta lkaboutdatabases.com...
What is the query to obtain a list of all the tables having the maximum
number of rows in descending order?

Cheers,
Sandeep.


What is "maximum number of rows"? Do you mean the number of rows sorting in
descending sequence?

You need to run runstats on all tables, and then look at the syscat.tables
view for the number of rows in the table. This is documented in SQL
Reference Vol 1, in the Appendix.
May 15 '06 #2
From a command line after connect:
db2 select tabname, card from syscat.tables order by card desc

This presumes that you have run stats and they are current.

HTH, Pierre.

--
Pierre Saint-Jacques
SES Consultants Inc.
514-737-4515
"shsandeep" <sa**********@gmail.com> a écrit dans le message de news:
c7******************************@loc...tdatabases.com...
What is the query to obtain a list of all the tables having the maximum
number of rows in descending order?

Cheers,
Sandeep.


May 15 '06 #3
If you don't have runstats, it's a simple UNION ALL.

SELECT 't1', COUNT(*) FROM T1 UNION ALL
SELECT 't2', COUNT(*) FROM T2 UNION ALL
SELECT 't3', COUNT(*) FROM T3 UNION ALL
SELECT 't4', COUNT(*) FROM T4 UNION ALL
SELECT 't5', COUNT(*) FROM T5
ORDER BY 2 DESC
To create the UNION ALL statement:

SELECT VARCHAR('SELECT ''' || TabName || ''', COUNT(*) FROM <schema>.'
|| RTrim(TabName) || ' UNION ALL \', 75) FROM SysCat.Tables WHERE
TabSchema = '<schema>'

The chop off the final UNION ALL and add ORDER BY 2 DESC.

The VARCHAR(75) works for me and keeps it within the client window
without newlines. YMMV.

B.

May 15 '06 #4

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

Similar topics

1
by: Dusan Chromy | last post by:
Hi, I was told there is a feature in Oracle to set up a table to have a limit on the maximum number of rows in it. By attempt to insert more rows, the oldest rows should get deleted...
8
by: Greg | last post by:
Hello, I've to manage many 'table' (having same scheme) on the same server. And I ask myself what could be the best to do (and if you know, why) : Creating as many database (the name would...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
4
by: sandip | last post by:
Hi, Can anyone tell me how to calculate the ctual disk space needed for a table? The record length and number of records are known. A rough estimate of the disk space would suffice. Please...
3
by: Kriston-Vizi Janos | last post by:
Dear Mr. Kern, and Members, Thank you very much for the fast answer, my question became over-simplified. My source code is appended below. It uses two text files (L.txt and GC.txt) as input...
5
by: Bob Stearns | last post by:
I have a table t1(id, other stuff) with 4 dependent (unrelated) tables ta(id, date, other stuff a), tb(id, date, other stuff b), tc(id, date, other stuff c), td(id, date, other stuff d). Any or all...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
4
by: Mr. DOS | last post by:
IBM DB2 UDB Is there a SQl query I can send from the web server that will return a list of tables currently in the LOAD PENDING state? LOAD QUERY is not quite waht I'm looking for. Thanks!
5
by: adam.kleinbaum | last post by:
Hi there, I'm a novice C programmer working with a series of large (30,000 x 30,000) sparse matrices on a Linux system using the GCC compiler. To represent and store these matrices, I'd like to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.