473,404 Members | 2,178 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,404 software developers and data experts.

how to select a table that has most columns using syscat?

hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

thanks in advance

May 22 '07 #1
4 4692
Ian
d0m_at0m wrote:
hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?
I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;

May 22 '07 #2
On May 23, 4:30 am, d0m_at0m <2lazy2sl...@gmail.comwrote:
hello,

how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

thanks in advance
even this may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)

May 23 '07 #3
On May 23, 4:54 am, Ian <ianb...@mobileaudio.comwrote:
d0m_at0m wrote:
hello,
how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;
even it may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)

May 23 '07 #4
situ wrote:
On May 23, 4:54 am, Ian <ianb...@mobileaudio.comwrote:
>d0m_at0m wrote:
hello,
how to select a table that has a highest amount of columns (compared
to other tables) using syscat?

I can't imagine how this would be useful, but:

select tabschema, tabname, count(*) as num_cols
from syscat.columns
group by tabschema, tabname
order by 3 desc
fetch first 1 row only;

even it may work i think ..

select * from syscat.tables
where colcount=(select max(colcount) from syscat.tables)
SELECT *
FROM syscat.tables
ORDER BY colcount DESC
FETCH FIRST 1 ROW ONLY

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
May 23 '07 #5

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

Similar topics

3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
10
by: Jean | last post by:
Hi, how to know for a particular table if it is organized by index, and which one ? reorg table index ind1 -> the table is organised by ind1 i wan't to know that for all table thx
3
by: selma | last post by:
I am puzzled by visual explain for a simple query ( select * from mytable ) chooses an index scan. That index has only a single column and the table has 30 columns not covered by the index. When...
5
by: Markus | last post by:
I created a Stored Procedure like this: CREATE PROCEDURE myProcedure(IN a_tabschema VARCHAR(20)) DYNAMIC RESULT SETS 1 LANGUAGE SQL BEGIN DECLARE rs CURSOR WITH RETURN FOR SELECT * FROM...
7
by: Bob Stearns | last post by:
Several weeks ago I asked what comments I could pass to DB2 in a SELECT statement. I don't remember whether I said via PHP/ODBC. I was assured that both /* */ style comment blocks and -- comment...
5
by: Konstantin Andreev | last post by:
Recently I became interested, - Are the data, bulk loaded in the table with LOAD utility, consume the same disk space as loaded with IMPORT utility? The answer turned out to be NOT ! Here is a...
5
by: RGow | last post by:
Hi all, Is there a way to retrieve or reconstruct the SQL that was used to create a particular table in DB2? I'm looking for something similar to the contents of the 'SYSCAT.ROUTINES.TEXT', but...
4
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,...
2
by: Okonita | last post by:
Hi all, How can I implement using REORGCHK to tell REORG what DB2 UDB v8 tables, etc to perform REORG on? Any example script will be highly appreciated. Okonita
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.