How can count no of rows in all tables in one schema
hi all
i want to cound no of rows in my schema ( all tables)
eg. i have 36 tables
i want to know no of rows in every tables in only one query through sql or plsql
how can i do..
regards
mohammadi
Message was edited by:
Mohdidubai52
hi
thanx for ur reply
but i got error....
SQL> ED
Wrote file afiedt.buf
1 DECLARE
2 v_rowNo NUMBER := 0;
3 v_sum NUMBER := 0;
4 v_tableName VARCHAR2(100);
5 CURSOR c1 IS
6 SELECT table_name
7 FROM user_tables;
8 BEGIN
9 FOR counter IN c1 LOOP
10 DBMS_OUTPUT.PUT_LINE(counter.table_name);
11 EXECUTE IMMEDIATE 'SELECT COUNT(1) FROM ' || counter.table_name INTO v_ro
wNo;
12 v_sum := v_sum + v_rowNo;
13 END LOOP;
14 DBMS_OUTPUT.PUT_LINE('Number of rows: ' || v_sum);
15* END;
16 /
DECLARE
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at line 11
again
thanx
regards
Mohammadi
Similar Messages
-
How to delete all rows in all tables of a schema in Oracle?
Hi all,
I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
may you help?
Edited by: user8105261 on Nov 25, 2009 11:06 PMuser8105261 wrote:
Hi all,
I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
may you help?
Edited by: user8105261 on Nov 25, 2009 11:06 PMA typical way to reset a schema (e.g. to recreate a schema on the test database) is totally different.
1) Drop the user
2) recreate the user including table scripts from
2a) your version control system
2b) from a export dumpfile using the "nodata" option while importing -
Rows in all tables in one query
Hi All,
How can i find the numbers of rows (records) in all the tables except system tables with single query.
In one tran table i have around 10,00,000 (TEN LACS) rows. while processing it take time. Plz suggest some solution for this.
Regards,
MummyHi,
You could use the NUM_ROWS column in the ALL_TABLES table. This column only gets populated if you collect statistics on the relevant tables though.
See: http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2105.htm#REFRN20286
You can analyze the relevant tables first and then use a SUM. For instance this query gets the total number of rows in the tables in the schema MAST:
select sum(num_rows) from all_tables where owner = 'MAST';
Regards,
Marco
=
www.marcostuijvenberg.nl -
All columns of all table in one schema
Hi
All,
Oralce 10.2.0.3
I want to count all columns in all the table in one particular schema.
How can I do that?
which view i should use to count all cloumns of all tables in particular schema?
Thanksvishal patel wrote:
we needed for our data conversion project..I don't know how you'll use the number of columns in all a schema for data conversion. Some columns are duplicated (e.g. PK/FK), should they really count for two ?
A data conversion means you should actually know what are the columns used for, not how many they are.
one more question that count include hidden columns
what is hidden column used for ? I can not see those columns in actual table.See here an example :
Re: Difference btwn user_tab_cols & user_tab_columns
Nicolas. -
How can I combine post to two different tables with one form?
I am trying to create a "phantom" record in a table to be used later in a report. How can I create a form and properly $_POST to two different tables? Thanks for any suggestions!
In POST processing, just do the insert to one table, followed by the insert to the second table. I don't understand where you are getting stuck.
Sometimes when we do an insert, we need the auto-generated ID from the newly created record as a "foreign key" for the record created in the second insert. MySQL has a nifty solution for that. The specific code depends on whether you are using the mysql, mysqli or PDO database connection. -
Analyze all tables of one schema
hi,
the analyze table command is:
analyze table hr.employees compute statistics;
Now I want analyze all tables in the hr schema
how can I do it in a easy way,
thanks,
Zhiwei.the only way to disable monitoring (globally) is to set statistics_level=basic.Exactly.
SYS@db102 SQL> select table_name,monitoring from dba_tables
2 where table_name like 'TEST%';
TABLE_NAME MON
TEST_P YES
TEST_MV YES
TEST_F YES
TEST11 YES
TEST YES
TEST_TABLE YES
TEST_PART YES
TEST_LOB YES
TEST_EMP YES
TESTDECIMAL YES
TEST3 YES
TEST1_DL2 YES
TEST01 YES
13 rows selected.
SYS@db102 SQL> alter system set statistics_level=basic;
System altered.
SYS@db102 SQL> select table_name,monitoring from dba_tables
2 where table_name like 'TEST%';
TABLE_NAME MON
TEST_P NO
TEST_MV NO
TEST_F NO
TEST11 NO
TEST NO
TEST_TABLE NO
TEST_PART NO
TEST_LOB NO
TEST_EMP NO
TESTDECIMAL NO
TEST3 NO
TEST1_DL2 NO
TEST01 NO
13 rows selected.
SYS@db102 SQL> that's what I meant by "in 10g you have to do it explicitly". -
How can i add a row in a table
Hi experts,
i have a problem where i can´t find any answer. Maybe one of you have one.
I have a scenario which is very similar to a MAM-Szenario. I'm using MI 7.1 and developing wit the newest NWDS in WebDynpro for Laptops.
I download Notification headers and as a dependend table the notification tasks. Now the user should be able to add a new task in the client if it not exists on the database.
Can anyone tell me how it is possible to dump a new entry to the database if the query, which should extract the right task is not available?
Thanks for a fast answer.
MathiasHi Mathias,
If you are developing applications using MI 7.1 , then Bapi wrappers are required to communicate with the backend system.If you want to create anything in the client and if you want it to be reflected in the backend system , then a create bapi wrapper is a must .
Please use this link to know more about different kinds of bapi wrappers :
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0baafd6-52fa-2910-c6a8-fbb9399cb4ab
After you are done with creating the bapi wrapper , just do a <model instance>.commit in your client.
Regards,
Madhu. -
How can I label my rows on numbers so I can keep a running count? Dave
How can I label my rows on numbers so I can keep a running count?
i would like to number from 1 to 150 by highlighting and use a function command
Dave
Name Address Email
Ex 1
2
3
4
150Add a column to the left of column A (it will become column A).
Assuming you want to start with the first "name" in Row 2 (and NOT number the header row):
Two methods:
1.
In cell A2, enter =ROW()-1
Grab the Fill Handle (small circle, bottom right of the selected cell) and drag down to fil the formula into the rest of the cells in the column.
If the formula is placed in ALL non-header row cells in the column, it will automatically fill into any rows added to the table.
If rows are inserted or removed, numbers below the inserted/removed row will be automatically adjusted.
2.
In cell A2, enter a 1
In cell A3, enter a 2
Select both cells.
Grab the Fill Handle and drag down to the rest of the cells in the column.
These are fixed numbers. They will not be automatically filled into new rows added to the table, nor will they automatically update when rows are inserted into the table or removed from the table.
To add more numbers, select the last two cells currently containing numbers, drag the Fill Handle down.
Regards,
Barry -
How can I use multiple row insert or update into DB in JSP?
Hi all,
pls help for my question.
"How can I use multiple rows insert or update into DB in JSP?"
I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
With thanks,That isn't true. Different SQL databases have
different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
and there are also a lot of different ways of talking to
SQL databases that are possible in JSP, from using
plain old java.sql.* in scriptlets to using the
jstlsql taglib. I've done maintenance on both, and
they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
Well, sure. As long as you only want to update rows
with the same value in column 2. I had the impression
he wanted to update a whole table. If he only meant
update all rows with the same value in a given column
with the same value, that's trivial. All updates do
that. But as far as I know there's know way to update
more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
Unless you're using MySQL, for instance. I only have
experience with MySQL and M$ SQL Server, so I don't
know what PostgreSQL, Oracle, Sybase, DB2 and all the
rest are capable of, but I know for sure that MySQL
can insert multiple rows while SQL Server can't (or at
least I've never seen the syntax for doing it if it
does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
Don't assume that all SQL databases are the same.
They're not, and it can really screw you up badly if
you assume you can deploy a project you've developed
with one database in an environment where you have to
use a different one. Even different versions of the
same database can have huge differences. I recommend
you get a copy of the O'Reilly book, SQL in a
Nutshell. It covers the most common DBMSes and does a
good job of pointing out the differences.Yes, I understand that.
It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing. -
How can I add a row into a JTable with JButton
Hi all. I have the following code:
package gui;
import db.*;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
public class FoundersTable extends AbstractTableModel{
private static final int COLUMNS = 8;
private String columnNames[] = {"��� ����", "���", "�������", "�������", "���������", "��������",
"����� �� ����������", "������ �� ����, �����"};
private ArrayList data;
public FoundersTable(){
data = new ArrayList();
public int getRowCount() {
return data.size();
public int getColumnCount() {
return columnNames.length;
public String getColumnName(int colIndex) {
return columnNames[colIndex];
public Object getValueAt(int rowIndex, int columnIndex) {
return ((ArrayList)data.get(rowIndex)).get(columnIndex);
public void setValueAt(Object value, int rowIndex, int columnIndex) {
((ArrayList)data.get(rowIndex)).set(columnIndex, value);
fireTableCellUpdated(rowIndex, columnIndex);
public void addRow(ArrayList neueZeile) {
data.add(neueZeile);
int index = data.size() - 1;
fireTableRowsInserted(index, index);
public void removeRow(int index) {
data.remove(index);
fireTableRowsDeleted(index, index);
public void removeAllRows() {
data.clear();
fireTableRowsDeleted(0, 0);
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}Now in my MainJFrame class I have one button for additing and one button for removing a selected row. How can I add/remove rows with this two buttons.
ThanksNo my question is how can I add and remove rows WITH buttons My point was the code is the same. You use the addRow(...) method. Why did you write an addRow(...) method if you aren't going to use it?
I don't understand your problem. Do you not know how to write an ActionListener? -
How to count number of rows in table
can I get number of row in table except Count(*) in pl/sql
is there any other wayAlso posted and answered here
how to count number of rows in table
count(*) will be the fastest way. It is only slow if the table has a vast number of rows, in which case why do you need to know the tables has 73552436467721 rows and not 73552436467737 rows. It doesn't seem to be much use. Either that or you are counting them a lot, which again seems rather pointless. -
Lost FRONT ROW after completing download of OS Mavericks. How can I recover FRONT ROW?
Have eventually managed to download Mavericks on my 2009 macbook ( at 2am!!!). Installation fine BUT I no longer have FRONT ROW on my system. Is this a gremlin? How can I get it back? All assistance greatly appreciated.
Front Row was withdrawn with the introduction of Lion as it does not officially work with later versions of OS X. Apple prefer you to use AppleTV.
Other threads here suggest a way of having Front Row with Mavericks. I have no idea of they work. -
How can I display the rows into columns.
How can I display the rows into columns. I mean
Create table STYLE_M
(Master varchar2(10), child varchar2(10));
Insert itno style_m
('MASTER1','CHILD1');
Insert itno style_m
('MASTER2','CHILD1');
Insert itno style_m
('MASTER2','CHILD2');
Insert itno style_m
('MASTER3','CHILD1');
Insert itno style_m
('MASTER3','CHILD2');
Insert itno style_m
('MASTER3','CHILD3');
Note : The Master may have any number of childs.
I want to display like this..
Master child1, child2, child3, .......(dynamic)
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3
Sorry for disturbing you. Please hlp me out if you have any slution.
Thanks alot.
Ram DontineniHere's a straight SQL "non-dynamic" approach.
This would be used if you knew the amount of children.
SELECT
master,
MAX(DECODE(r, 1, child, NULL)) || ' ' || MAX(DECODE(r, 2, child, NULL)) || ' ' || MAX(DECODE(r, 3, child, NULL)) children
FROM
SELECT
master,
child,
ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r
FROM
style_m
GROUP BY
master
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3 Since you said that the number of children can vary, I incorporated the same logic into a dynamic query.
SET AUTOPRINT ON
VAR x REFCURSOR
DECLARE
v_sql VARCHAR2(1000) := 'SELECT master, ';
v_group_by VARCHAR2(200) := 'FROM (SELECT master, child, ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r FROM style_m) GROUP BY master';
v_count PLS_INTEGER;
BEGIN
SELECT
MAX(COUNT(*))
INTO v_count
FROM
style_m
GROUP BY
master;
FOR i IN 1..v_count
LOOP
v_sql := v_sql || 'MAX(DECODE(r, ' || i || ', child, NULL))' || ' || '' '' || ';
END LOOP;
v_sql := RTRIM(v_sql, ' || '' '' ||') ||' children ' || v_group_by;
OPEN :x FOR v_sql;
END;
PL/SQL procedure successfully completed.
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3I'll point your other thread to this one. -
How can i find Duplicate Rows in forms6i
Hi,
How can i find duplicate rows in multiple record in forms6i.
Thanks
Raghu.KOops, sorry for misreading your question. (However the SQL I gave you above is also very handy, and worth saving.)
Okay, this is off the top of my head and untested, but might just work. Assuming that your data block name is MYBLOCK, and that the item that you want to check for dups on is named MYNUM, create an item-level WHEN-VALIDATE-ITEM trigger with the following code.
declare
l_newest_record number(10) := :system.cursor_record;
l_newest_mynum number(10) := :myblock.mynum;
l_dup_found boolean := false;
begin
-- In this loop, we skip backwards through all new records to look for dups.
while :system.cursor_record > 1 loop
previous_record;
if :system.record_status = 'NEW' then
if :myblock.mynum := l_newest_mynum then
l_dup_found := true;
exit; -- Dup found!
end if;
else
exit; -- We've gone backwards past the first new record.
end if;
end loop;
-- In this loop, we return to the current record.
while :system.cursor_record < l_newest_record loop
next_record;
end loop;
if l_dup_found then
raise duplicate_row_found; -- user-defined exception
end if;
end;
The above code only checks for dups in the new form records. It assumes that a unique constraint in the database will deal with records actually committed.
Armand -
What is the problem with native dynamic sql when counting rows in all table
what is the problem with native dynamic sql when counting rows in all table?Giving an error "table or view does not exist". Thanks.
DECLARE
v_sql_string varchar2(1000);
v_no_of_rows number;
BEGIN
for i in ( select table_name from all_tables )
loop
v_sql_string := ' select count(1) from ' || i.table_name;
dbms_output.put_line( v_sql_string );
--execute immediate v_sql_string into v_no_of_rows;
end loop;
END;Usually your problem can be described with 'Who cares'. I mean, for what reason do you do this? I doubt that there's a business need to get 100 % accurate answers for this. Normally such things are used to get a picture about the growth of data.
Personally I would prefer to have up-to-date statistics for all tables and just query the number of rows from there. Sufficient for me in < 99 % of all cases.
Just my $ .02...
Maybe you are looking for
-
I used to use Aperture but now I use Adobe Lightroom to store and edit my photo's. Is there a way to view the photo folders on apple TV or should I still use Aperture with the files referenced, instead of being in the consolidated aperture library, j
-
ClickOnce, Windows 8+, SmartScreen, Unknown Publisher & EV Certificate
In an attempt to eliminate the Smart Screen warning in Windows 8+, my company purchased an EV Certificate from Symantec to use for a software product we produce. Specifically it is called: Symantec Class 3 Extended Validation Code Signing CA – G2. We
-
i ordered a book on africa (4th one). she hasn't received it yet. the others came in two weeks. not sure what to do <Message was edited by Host>
-
How to find and replace with sequential values?
im building a website. it contains 12 main images per page and luckily according to my design the source code per page contains 12 <img> tags only (rest is background and stuff). now for many pages i keep using a particular page as template and then
-
Reader SCUP confusion - flawed detection logic?
I'm starting to test the deployment of Reader updates via SCUP. What I'm seeing is that Config Manager says I have X number of clients that require Reader 11.0.n - fine. It seems confused about what systems need which update, though. E.g. it says th