Row count of all tab's in my DB. [message #395401] |
Wed, 01 April 2009 05:45  |
mjkreddy1927
Messages: 20 Registered: February 2007
|
Junior Member |
|
|
Hi,
I want Row Count of all the tables in my DB.
select count(*) from ;
this is for count on individual table.just like this i need for all the tables in my DB.
Can any one Helpme out...
i need sql for this...
Any efforts are appreciated
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: Row count of all tab's in my DB. [message #395423 is a reply to message #395401] |
Wed, 01 April 2009 07:22   |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
select
table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) cnt from '||table_name))
,'/ROWSET/ROW/CNT')) count
from user_tables;
I will leave it you to figure out what this query is doing.
Regards
Raj
|
|
|
|
|
|
|
|
| Re: Row count of all tab's in my DB. [message #395450 is a reply to message #395431] |
Wed, 01 April 2009 08:30   |
trivendra
Messages: 211 Registered: October 2007 Location: Phoenix
|
Senior Member |
|
|
This is real amazing..
I have tried but I can see only 7 rows returned, am I missing some thing.
SQL> SELECT COUNT (1)
FROM all_tables
COUNT(1)
----------
1423
1 row selected.
SQL> SELECT table_name
,to_number (extractvalue (XMLTYPE (dbms_xmlgen.getxml ('select count(*) cnt from ' || table_name))
,'/ROWSET/ROW/CNT')) COUNT
FROM all_tables
TABLE_NAME COUNT
------------------------------ ----------
DUAL 1
SYSTEM_PRIVILEGE_MAP 166
TABLE_PRIVILEGE_MAP 24
STMT_AUDIT_OPTION_MAP 205
OL$ 0
OL$HINTS 0
OL$NODES 0
7 rows selected.
Thanks
Trivendra
|
|
|
|
|
|
| Re: Row count of all tab's in my DB. [message #395455 is a reply to message #395450] |
Wed, 01 April 2009 08:49   |
 |
Michel Cadot
Messages: 68774 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
As you call a procedure roles are not enabled and so all_tables is the same as user_tables if you have no direct access to others table.
Actually, depending on your version you either has only your direct accessible tables or has an error like:
ORA-19202: Error occurred in XML processing
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_XMLGEN", line 288
Which one is yours?
Regards
Michel
[Updated on: Wed, 01 April 2009 08:53] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: Row count of all tab's in my DB. [message #395470 is a reply to message #395462] |
Wed, 01 April 2009 09:48   |
trivendra
Messages: 211 Registered: October 2007 Location: Phoenix
|
Senior Member |
|
|
Thanks Michel,
I tried on the schema which has only synonyms created, they have 'SELECT' grant with them, this also include the SYS and SYSTEM objects with PUBLIC grant.
This schema has, as such no objects of its own, that's why I tried this on ALL_TABLES.
I can see the same error on the execution.
Is this depends upon the GRANT for PUBLIC or specific to USER.
Thanks
Trivendra
|
|
|
|
|
|
|
|
|
|
|
|
|
|