Row count of all the table under any schema

Some times we may get requirement to gather the row count of all the tables under any specific schema.

So there is a very easy way to get the same detail as below.


Query :

SELECT 

table_name, 

TO_NUMBER( 

EXTRACTVALUE( 

XMLTYPE( 

DBMS_XMLGEN.getxml('SELECT COUNT(*) c FROM '||table_name)) 

,'/ROWSET/ROW/C')) cnt 

FROM user_tables order by 

table_name; 



Demonstration :

SQL> show user

USER is "BRIJ"

SQL> set lines 300 pages 1000

SQL> col TABLE_NAME for a22

SQL> SELECT

table_name,

TO_NUMBER(

EXTRACTVALUE(

XMLTYPE(

DBMS_XMLGEN.getxml('SELECT COUNT(*) c FROM '||table_name))

,'/ROWSET/ROW/C')) cnt

FROM user_tables order by

table_name;

TABLE_NAME                    CNT

---------------------- ----------

COUNTRY                         4

DPT                             8

EMP                            20

JOBS                           12

JOB_GRADE                       6

JOB_HIST                       10

LOC                             5

REGION                          4

 

8 rows selected.


1 comment:

  1. All of the beneficial casinos here are are|listed under are} legitimate sites that maintain players protected. They respect playing rules and age restrictions, offering a wonderful actual cash gaming 카지노 사이트 expertise in a secure setting devoted to players' welfare and security on-line. After security and legitimacy, you wish to take a look at|have a look at} the payout share of an online slot.

    ReplyDelete

Add new mountpoint on your linux server

  Below are the steps to follow for adding any new mount on you linux machine. [root@oem ~]# fdisk -l Disk /dev/sdb: 53.7 GB, 53687091200 by...