Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > Re: Get a COUNT...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 8843 of 9520
Post > Topic >>

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

by bwmiller16@[EMAIL PROTECTED] May 1, 2008 at 08:16 AM

On Apr 30, 3:05=A0pm, Lennart <Erik.Lennart.Jons...@[EMAIL PROTECTED]
> wrote:
> On Apr 30, 6:41 pm, --CELKO-- <jcelko...@[EMAIL PROTECTED]
> wrote:
>
> > Is there a simple way to get =A0a 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@[EMAIL PROTECTED]
 Do***ents]$ for t in `db2 -x "select tabname from
> syscat.tables where tabschema =3D 'LELLE' and type =3D 'T'"`; do db2
> "select '$t', count(1) from lelle.$t"; done
>
> 1 =A02
> -- -----------
> T1 =A0 =A0 =A0196608
>
> =A0 1 record(s) selected.
>
> 1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A02
> ---------------- -----------
> EXPLAIN_INSTANCE =A0 =A0 =A0 =A0 =A010
>
> =A0 1 record(s) selected.
>
> 1 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 2
> ----------------- -----------
> EXPLAIN_STATEMENT =A0 =A0 =A0 =A0 =A020
>
> =A0 1 record(s) selected.
>
> [...]
>
> /Lennart

#!/bin/sh

INSTANCE=3D$1
DB=3D$2

if [ -f /home/$INSTANCE/sqllib/db2profile ]; then
   . /home/$INSTANCE/sqllib/db2profile
fi

db2 -t -x -n +p<<DB2>COUNTALL.tmp 2>&1

connect to $DB;

select distinct 'connect to $DB ;' from sysibm.sysversions ;

select distinct substr('select count(*) from '||rtrim(tabschema)||'.'||
rtrim(tabname)||' ;',1,80) from  syscat.tables Where type =3D 'T' and
not tabschema like'SYS%' order by 1 asc ;

DB2

db2 -tvf COUNTALL.tmp
 




 5 Posts in Topic:
Get a COUNT(*) for all tables in a schema?
--CELKO-- <jcelko212@[  2008-04-30 09:41:45 
Re: Get a COUNT(*) for all tables in a schema?
ChrisC <cunningham.cb@  2008-04-30 09:56:09 
Re: Get a COUNT(*) for all tables in a schema?
Serge Rielau <srielau@  2008-04-30 13:19:46 
Re: Get a COUNT(*) for all tables in a schema?
Lennart <Erik.Lennart.  2008-04-30 12:05:53 
Re: Get a COUNT(*) for all tables in a schema?
bwmiller16@[EMAIL PROTECT  2008-05-01 08:16:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 20:38:33 CST 2008.