Count the number of rows in each table
I have a list of table names, how to write a query to find out the number of rows in each table.Select the table table_name from all_tables where owner = 'XXX' and num_row > 100
or
Select the table table_name from all_tables where owner = 'XXX' and sample_size > 100
isn't quite working.
Why?
Thanks in advance,
Published by: mpt_fz on January 12, 2010 12:06
In recent versions of the db (11g):
SQL> select table_name, column_value cnt
from user_tables, xmltable (('count(ora:view("'||table_name||'"))'))
where table_name in ('EMP', 'DEPT', 'BONUS')
/
TABLE_NAME CNT
------------------------------ -----
BONUS 0
DEPT 5
EMP 14
Tags: Database
Similar Questions
-
Count the number of rows in a table (s)
Hi all
I have a TKT_PRIORITY_LK table that I want to count the number of rows returned by a priority level... say Low, Medium, High, critical. I want to be able to count how many of each created are they, instead returning ID instead, if making any sense... Can you please help with this.
Example; Select count (*) in TKT_PRIORITY_LK
PRIORITY group
Kind regards
Sandrine
Try this
Select a.PRIORITY, count (*) from TKT_PRIORITY_LK a, TKT_TICKET_MAIN b
where a.id = b.PRIORITY_ID
A.PRIORITY group
-
Count the number of rows in a table
Hello
I have a requirement. I want to frame a SQL, which takes the name of schema as input and returns the tables belonging to this scheme and the number of lines in a particular table.
An example of output:
===========
Can someone help me to make a request for the same.Table No. of Rows ~~~~ ~~~~~~~~ A 123 B 126 C 234 . . .
Kind regardsIf you are not sure on the statistics collected, then you need dynamic sql...
DECLARE VNUM NUMBER:=0; VSQL VARCHAR2(4000); vcount number := 0; BEGIN DBMS_OUTPUT.ENABLE(NULL); DBMS_OUTPUT.PUT_LINE(RPAD('TABLE NAME',30,' ')||' '||RPAD('ROW COUNT',10,' ')); DBMS_OUTPUT.PUT_LINE(RPAD('-',30,'-')||' '||RPAD('-',10,'-')); FOR C1 IN (SELECT TABLE_NAME,OWNER FROM ALL_TABLES WHERE OWNER='SCOTT' ORDER BY OWNER,TABLE_NAME) LOOP VSQL := 'SELECT COUNT(*) FROM '||C1.OWNER||'.'||C1.TABLE_NAME; EXECUTE IMMEDIATE VSQL INTO VNUM; DBMS_OUTPUT.PUT_LINE(RPAD(C1.TABLE_NAME,30,' ')||' '||RPAD(VNUM,10,' ')); vcount := vcount +1; END LOOP; DBMS_OUTPUT.PUT_LINE(RPAD('-',length(vcount)+6,'-')); DBMS_OUTPUT.PUT_LINE(vcount||' Rows.'); DBMS_OUTPUT.PUT_LINE(RPAD('-',length(vcount)+6,'-')); END; / TABLE NAME ROW COUNT ------------------------------ ---------- BONUS 0 DEPT 4 EMP 14 SALGRADE 5 ------- 4 Rows. ------- PL/SQL procedure successfully completed. Elapsed: 00:00:00.44
Personally, I think this is a time to kill the process... ;)
HTH,
Prazy -
Hello
How to find the number of rows in each table of a database just by using a SQL query.
and do not use the data dictionary tables also... is possible...?
Thank you
MJIt can be done in a single SQL like->
satyaki> satyaki>select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production Elapsed: 00:00:00.00 satyaki> satyaki> satyaki>SELECT table_name, 2 DBMS_XMLGEN.getxmltype ('SELECT Count(*) c FROM ' || table_name).EXTRACT ('//text()').ge tnumberval() tot_rows 3 FROM user_tables; TABLE_NAME TOT_ROWS ------------------------------ ---------- QUESTIONTYPE 0 SRGROUPTABLE 1 ST_TEST 4 REGISTER 0 DEB_1 2 EMP1 0 6 rows selected. Elapsed: 00:00:12.04
The credit goes to Michael. ;)
Kind regards.
LOULOU.
-
Count the number of rows returned from each view in USER_VIEWS
For each USER_VIEWS view, I would return the name, creation date, last modified dateand the number of rows returned by this view.
Here's what I have so far:
Returns:col object_name format a20 select object_name, created, last_ddl_time from user_objects where object_type = 'VIEW'
How can I add a last column that counts the number of rows returned by this view?OBJECT_NAME CREATED LAST_DDL_TIME -------------------- --------- ------------- AISLE_AVG 11-FEB-12 11-FEB-12 COURSE_AVG 11-FEB-12 20-FEB-12 EXE_12_VIEW 11-FEB-12 21-FEB-12 L1_P2 17-FEB-12 17-FEB-12 L1_P3 17-FEB-12 17-FEB-12 L1_P4 17-FEB-12 17-FEB-12 L1_P5A 17-FEB-12 17-FEB-12 L1_P5B 17-FEB-12 17-FEB-12 LAB3_1A 12-FEB-12 20-FEB-12 LAB3_1B 12-FEB-12 20-FEB-12 LAB3_2A 12-FEB-12 20-FEB-12 LAB3_2B 12-FEB-12 20-FEB-12 LAB5_1 19-FEB-12 19-FEB-12 LAB5_2 19-FEB-12 19-FEB-12 LAB5_3 19-FEB-12 19-FEB-12 LAB5_4 19-FEB-12 19-FEB-12 LAB5_5 19-FEB-12 19-FEB-12 LAB5_TIMES 19-FEB-12 19-FEB-12 LAB6_1 19-FEB-12 19-FEB-12 LAB7_VIEW 20-FEB-12 20-FEB-12 PROGRAMS 11-FEB-12 21-FEB-12 STUDENT_GPA 11-FEB-12 21-FEB-12 22 rows selected
EDIT - here is a dump of my paintings, and here are my views.
Edit2 - this is possible by using the DECODE function, by chance?The function...
CREATE OR REPLACE FUNCTION view_row_count (view_name VARCHAR2) RETURN NUMBER AS retval NUMBER; BEGIN EXECUTE IMMEDIATE 'select count(*) from '||view_name INTO retval; RETURN retval; END view_row_count; /
And now the query...
select object_name, created, last_ddl_time, view_row_count(object_name) as view_row_count from user_objects where object_type = 'VIEW'
-
How to count the number of nodes under each parent in any given xml
How to count the number of nodes under each parent in any given xml. for example the xml below was
books has 3 childern, library [1] has 4, [2] library has 6 and bookshop [3] has 2. is it possible to get the number of tags in a childnode duplicate IE library [1]
Book1 Tagus repeated twice... vice versa. do we need to make plsql lie we can achieve through sql
< book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
ACR < book3 > < / book3 >
ACR < book3 > < / book3 >
tray of < bookn_1 > < / bookn_1 >
adjusted cost base < bookn > < / bookn >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
< / books >
I tried this... query.
Select
XMLQUERY ('count($doc/Books/Bookstore[1]/descendant::*)' in the way of xmltype ("< books >
< library >
ABC < book1 > < / book1 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
(< / books > ')
as 'doc' of happy return) .getNumberVal () as node_count
of the double
Select
XMLQUERY ('count($doc/Books/descendant::*)' in the way of xmltype ("< books >
< library >
ABC < book1 > < / book1 >
ACR < book1 > < / book1 >
Lac < Book4 > < / Book4 >
< / book >
< library >
ABC < book1 > < / book1 >
BCA < book2 > < / book2 >
< / book >
(< / books > ')
as 'doc' of happy return) .getNumberVal () as node_count
of the double
How can I get the counts for each parent in a single query
Published by: user7955917 on August 24, 2012 07:26Generic function how you want the query to be.
If the structure is known in advance, as in your example a 'books' and then a 'library' root element, it's as simple as:
SQL> select x1.parent_id, x2.child_name, count(*) 2 from tmp_xml t 3 , xmltable( 4 '/books/bookstore' 5 passing t.object_value 6 columns parent_id for ordinality 7 , child_list xmltype path '*' 8 ) x1 9 , xmltable( 10 '/*' 11 passing x1.child_list 12 columns child_name varchar2(30) path 'name()' 13 ) x2 14 group by x1.parent_id, x2.child_name 15 order by x1.parent_id, x2.child_name 16 ; PARENT_ID CHILD_NAME COUNT(*) ---------- ------------------------------ ---------- 1 book1 2 1 book2 1 1 book4 1 2 bookn 1 2 bookn_1 1 2 book1 1 2 book2 1 2 book3 2 3 book1 1 3 book2 1 10 rows selected
If you want a generic solution that works without knowledge of the structure, you will need a recursive approach, and most importantly, you should know which nodes in distinct, I suppose that the leafs?
Also, please help if you can provide the link of reference on the function name() years what are the other expression, that I can use after the path
You can start reading the documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ
The clause PATH expects a XQuery expression however before 11.2, we can put only simple XPath expressions.
-
Game max fixed the number of rows in a table
Hi all
I created a table that should contain only one line and avoid the possibility to add other lines to it, I used the following:
It works, but it seems a bit heavy for me... Is there a better way to define a fixed/maximum number of rows in a table?CREATE TABLE <table_name> ( <field_1> <field_type> unique, ... <field_2> <field_type> CONSTRAINT <field_1_ck> CHECK (<field_1> = <value>) );
See you soon,.
Valerio
PS: how to view the code snippets in mode 'IDE-like' (i.e. fixed fonts) spaced, showing dashes, etc.?
Published by: valerio75 on February 4, 2010 01:48 - now shows the code correctlyPS: how to view the code snippets in mode 'IDE-like' (i.e. fixed fonts) spaced, showing dashes, etc.?
Put the
tag before and after your snippets. See the [FAQ|http://forums.oracle.com/forums/help.jspa] for more information regarding tags (scroll down a bit there) .
-
Count the number of rising edges in table 1 d
Hello
I wanted to measure the frequency of a pulse signal using a MCC DAQ via libraries ULx in Labview. I have two methods to do this:
1. use the analog inputs:
Since data acquisition has only 1 ADC, I use a commune VI acquisition for all channels and create a multi-dimensional array with different channels in rows 0-15. Then divide them by using the function "Array Index". I think this split removes the parameter 'time' to the wave, since it is now a table 1 d. But I already know that there will be 1000 samples each 100 m everything I want to do now is to count rising edges using a function and divide it by the 0.1 to obtain the frequency in Hz, but I don't know how. Can anyone help?
2. use the input frequency meter:
Because I can't use the DAQ assistant, I have to use the CI frequency-> counter 1ChanNSamp DBL 1 d in the ULx library. There is no reference to take aid to and I do not know if this method is good. I have no way of knowing since I do not have a signal generator. In addition, it does not work so far.
Help, please.
Thank you!
Thank you.
I note in your first post it is seems to want to get readings of speed about 10 times per second. To get a resolution of 1 Hz frequency direct count you need to get at least 2500 counts in a range of counting at the highest frequency. This means that you need to have at least a second. Measures of the time are another option.
Some preliminary calculations:
Period at 2500 RPM = 2500 Hz is 400,000 Americans.
Period at 2499 RPM = 2499 Hz is 400,160 to the United States.
You need to be able to resolve a difference of 160 ns period. To do this directly requires 6.25 MHz sampling rate. It is 25 times faster that your DAQ card can enjoy.
What other options are there? Consider only your Information.vi extract. He uses techniques of Fourier transformation and interpolation to find the frequency of a signal. I set up a quick test VI to check this. Using a sampling rate of 10 kech. / s and 1000 samples per read (10 reads per second), it has easily resolution of less than 0.1 Hz at both ends of the range of speed and largely independent of the amplitude. This is the way to go.
Lynn
-
Count the number of records in all tables with a querry URGENT please...
I downloaded ORACLE 9I DATA DUMP in my computer. There are number of tables. I need to know the tables with records more of say 100 or on the go. Is it possible... If so kindly let me know.
Second, the database that I downloaded, I discovered that Audit_ trial was not activated by cooking
' select name, value of v$ parameter.
where name like '% verification' and it turned out to be false.
Can we assume that the database in the server as the audit_trial has been disabled...
Published by: user1287492 on October 21, 2009 09:07Hello
Place the table name with quotes. Maybe that's the problem.
Try this code
select table_name, to_number( extractvalue( xmltype( dbms_xmlgen.getxml('select count (*) c from "'||table_name||'"' )) ,'/ROWSET/ROW/C')) COUNT FROM USER_TABLES where iot_type IS NULL /
SS
-
function should return the number of rows in a table
Hello world
I wrote an entry function is the name of the table and the function should return how many line in the table.
the table name can change.
It is possible
Published by: Balajiraam on March 18, 2011 05:33Hello
Try this
CREATE OR REPLACE FUNCTION GETCOUNT(TABLE_NAME IN VARCHAR2) RETURN NUMBER IS TMPCOUNT NUMBER; TMPSQL VARCHAR2(1000); BEGIN TMPSQL := 'SELECT COUNT(*) FROM ' || TABLE_NAME; EXECUTE IMMEDIATE TMPSQL INTO TMPCOUNT; RETURN TMPCOUNT; END;
see you soon
VT
-
How to find the partitioned tables and the number of sheets in each table
Hello friends,
I have a scheme called ICS_OWNER where I partitioned and tables not partitoined.
I want to list all the tables that are partitioned.
and also
I want to know what partitions exists in every partitioned table.
with respective schema specified
Thank you/KumarWhen you have questions like this, you don't ask here.
but you take your (or should I say 'your') keyboard
and type
Select *.
dict
where table_name like ' % PART %.
/All the dictionary views are listed in the DICT.
----------
Sybrand Bakker
Senior Oracle DBA -
get the number of rows affected by their table top
Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.
oscarjavier99 wrote:
Hello, I need to count the number of rows updated in table form. In the process of ApplyMRU, I can use the string substitution #MRU_COUNT # to show the lines updated in a success message, but I need to get this value and store it on a table. Any help would be much appreciated. Thank you.
For that you would benefit from the APEX$ ROW_STATUS integrated substitution string.
1. create a page element display only (in my case P15_UPDATED_ROWS) Save Session State set to Yes and the Type of Condition is set to never.
2. Add a calculation after the shows with a Type of static assignment and calculation value 0 to reset the counter whenever the page is sent.
3. Add an On submit - after calculations and Validations process of PL/SQL page linked to your tabular presentation with a Status of Type PL/SQL Expression and Expression 1
:apex$row_status = 'U'
and the code of the following process ::p15_updated_rows := :p15_updated_rows + 1;
If you don't actually means "day" in the strict sense, and then change the status of process to include possible APEX$ ROW_STATUS 'C', 'U', and "D" values as needed. If you want to count all created, updated and deleted lines, do not add the condition to the process, but make sure the extended run is set to createand changed lines.
-
I created a table and partitioned on the date of the entry and added a local partitioned index.
Now, I use a query to extract "num_rows" of user_tab_partitions to know the number of rows in each partition.
Getting this value as null num_rows, wonder why?
After looking to explain the Plan after interrogation ("select * from my_table1 where entry_date = 1 January 2015" ;))
to find out if she actually partitioned table and its data in different partitions, I interpreted in effect because the query plan had a line like Partition_range (Single).
My Question is:
(a) is actually partitioned data (have I misinterpreted the Explain plan)
(b) why is the num_rows null column in the query (Pasted below)
(c) also in addition what difference it would have been if I had created a Global Index instead of the Local Index in my case?
The following code Snippet:
----------------------------------------------------------------------------------------------
create the table my_table1
(
roll_no number constraint my_table1_pk primary key,
date of entry_date
)
partition of range (entry_date)
(
PARTITION data_p1 VALUES LESS THAN (TO_DATE (December 31, 2014 ',' DD-MM-YYYY ""));
PARTITION data_p2 VALUES LESS THAN (MAXVALUE)
);
create an index only my_table1_indx on my_table1 (entry_date) local;----------------------------------------------------------------------------------------------
I now insert two lines:
insert into my_table1 values (1, to_date ('01-01-2015', ' dd-mm-yyyy'));
insert into my_table1 values (2, to_date('01-02-2015','dd-mm-yyyy'));----------------------------------------------------------------------------------------------
These have been inserted successfully, now using the query below shows num_rows column as null. I don't know why?
SELECT table_name, num_rows, high_value, nom_partition
Of user_tab_partitions
where table_name = 'MY_TABLE1 '.
ORDER BY table_name, nom_partition;----------------------------------------------------------------------------------------------
(a) is actually partitioned data (have I misinterpreted the Explain plan)
Yes, it is partitioned. You can query this particular partition SELECT * FROM my_table1 (data_p1) PARTITION to check that.
(b) why is the num_rows null column in the query (Pasted below)
As already mentioned that you have not collected statistics.
(c) also in addition what difference it would have been if I had created a Global Index instead of the Local Index in my case?
In fact, you have created two types of indexes without knowing (can be)! One is not partitioned (although this column is not partition key) and another is partitioned (LOCAL). They are MY_TABLE1_PK and MY_TABLE1_INDX. You can check that USER_INDEXES.
You can read this article to get an early jump on the partitioning of decision. Partition: Partition decisions
-
count the number of occurrence in the table with toplink
Hello!
There is no way to create a query with the expressionbuilder or... to count the number of occurences in my table?
I don't want to use the query " select count (*) from table .
Thank youNot sure about the question. You are looking to get the SQL "select count (*) table" to use the framework of expression TopLink or pull you that SQL already and want something else?
If you are looking just to get the count of a table/class, you can use a ReportQuery:
ReportQuery rquery = new ReportQuery (ClassToQueryOn.class);
rquery.addCount (); equivalent to count (*);session.executeQuery (rquery);
You can use a report query to return data instead of objects and use the criteria for selection as a normal read request.
Best regards
Chris -
Count the number of zero terms between non zero terms
Hello. I have a table of data of zero and nonzero (example: {1 2 56 2 3 0 0 0 0 0 2 3 5 2 3 5 2 0 0 0 0 32 43}) I need to count the number of zeros of each string of zeros and mark that number against the first zero no term following the string of zeros (NOTE (: string is used here as a description of a series of zeros, not a string variable). So the plot which coordinates since my example would be (5.2) and (4.32).
I'm clear on the way to the path, but I am unable to store only each final count of consecutive zeros without having unnecessary data in my plot.
Thanks in advance to all those who have advice!
-Mike
Do something like that?
EDIT: Minor Correction because of the additional function of decrement.
Maybe you are looking for
-
Then...
-
Is there anywhere I can download a replacement to Age of Empires II?
My CD has a scratch in there and when I try to install Age of Empires II, it stops when I reached a certain file.
-
Affected by an error message RunDLL Error Loading:C\Windows\kbepshsp.dll initially upward in normal mode. Download MSRT on the recommendation of the forum to run a full scan (already ran full scan using installed McAfee AV suite - found all OK, but h
-
Where to download the recovery of the system for x 230
Hey Lenovo Community! Where can I download the file for my x 230 laptop system restore. I replaced my hard drive with a new one and wanted a fresh State factory. Unfortunately, I have not create recovery discs and cannot create a. Thank you!
-
BlackBerry Blackberry OS 10.3.2.2474 Q10
I have a Q10-1 with OS 10.3.2.2474 SQN100 installed - my carrier (Koodo, Canada) has been long abandoned products Blackberry so if there are newer versions, I do not see Koodo releasing so I wonder y at - it later than that and if so, where can I get