Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
how to count total number of columns in DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jwell rymbei

New User


Joined: 14 Dec 2005
Posts: 22
Location: India

PostPosted: Thu Feb 23, 2006 6:14 pm    Post subject: how to count total number of columns in DB2
Reply with quote

hi,
our database have 220 tables. How can I count total number of columns in 220 tables.
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Feb 23, 2006 8:02 pm    Post subject: Re: how to count total number of columns in DB2
Reply with quote

jwell rymbei,

I think you're going to have to do something like this

Code:

SELECT SUM(A.R_C)  AS TOTAL_ROW_COUNT                                                 
  FROM                                                             
   (          SELECT COUNT(*) AS R_C FROM DB2.TABLE_1
    UNION ALL SELECT COUNT(*) AS R_C FROM DB2.TABLE_2
    UNION ALL SELECT COUNT(*) AS R_C FROM DB2.TABLE_3
    UNION ALL SELECT COUNT(*) AS R_C FROM DB2.TABLE_4                   
    ) A                                                             
;                                                                   


Best of luck,

Maybe someone can come up with a better way that you don't have to list each table.

Dave,
Back to top
View user's profile Send private message
jwell rymbei

New User


Joined: 14 Dec 2005
Posts: 22
Location: India

PostPosted: Thu Feb 23, 2006 8:55 pm    Post subject: how to count total number of columns in DB2
Reply with quote

select sum(colcount) from syscat.tables. i have tried with this and it worked fine.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Feb 23, 2006 9:03 pm    Post subject: Re: how to count total number of columns in DB2
Reply with quote

Hi jwell rymbei,

I just tried your query on my system and got an undefined name for "syscat.tables", Our systems must be set up differently.

Dave,
Back to top
View user's profile Send private message
prabs2006

Active User


Joined: 12 Jan 2006
Posts: 103

PostPosted: Fri Feb 24, 2006 10:46 am    Post subject:
Reply with quote

Hi David,

Can you please tell me how does ur above query work?

T & R
Prabs
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Skip records depends on count lakshmiibmmainframes DFSORT/ICETOOL 5 Sun Dec 24, 2017 9:51 pm
No new posts ISMF Difference between volume count ... upendrasri IBM Tools 2 Tue Dec 05, 2017 12:40 pm
No new posts Can EDCICONV convert EBCDIC to ASCII... natt.sut IBM Tools 3 Fri Nov 17, 2017 8:46 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us