Need Query to that generate count of rows of all tables

Hi
i need a query which gives the result of no.of rows in talbe and coresponding table name.
And then i need to compare the same with other DB schema
Thanks in advance

Hi User,
We can also get the count of rows for all the tables associated with a User, we can create a custom function which
uses the table name to return results.
  CREATE OR REPLACE FUNCTION TAB_ROWS_CNT (TAB_NAME IN VARCHAR2)
   RETURN NUMBER
AS
   TAB_CNT   NUMBER :=0;
BEGIN
   EXECUTE IMMEDIATE 'select count(*) from ' || TAB_NAME
      INTO TAB_CNT;
   RETURN TAB_CNT;
END;And query,
SELECT TABLE_NAME, TAB_ROWS_CNT (TABLE_NAME) ROW_CNT
  FROM USER_TABLES;Which gets us the count of Individual Tables for a user.
This is an just that we can do in this way also. But, use which is optimal.
Thanks,
Shankar

Similar Messages

  • Need An Algorithm That Generates Random Numbers

    Hi, I understand that there is a built-in random number generator. But, I need an algorithm that generator random numbers. Is there one available? Thanks.

    Hi, is the "Seminumerical Algorithms" a book?What
    the numbers 3141592621 and 907633385 stand for?The first is PI without a decimal... the second I
    don't know, it may as well be randomly picked.As far as I know the numbers aren't randomly picked. You want the distribution to be good, and the length of the serie should also be long. Some numbers causes the cycle to be short, or the distribution to be bad. I think there are articles that lists 'good' numbers.
    /Kaj

  • 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...

  • The biggest count of rows of sys tables

    Hii ??
    I want to learn how can I find the biggest count of rows of sys tables or
    which table has around 900000 records on sys user database oracle 10g??

    Hello;
    What purpose would knowing the row count in tables owned by SYS serve ? The query below will give you a fair idea of row counts in tables owned by SYS assuming that statistics have been recently gathered for these tablesselect table_name,num_rows from dba_tables where owner='SYS';Varad

  • Count of rows of a table in header

    Hi Experts,
    I am stuck in a tricky scenario.
    I need to get the count of rows of a table in a webi report in the header of the report.
    And the count should change dynamically according to the filtering done on the table.
    For eg.
    If I have 10 countries in a table, so table has 10 rows.
    Now the count on header should show 10.
    Now if we filter the column to 5 countries, the count on the header should change to 5.
    Any Idea's.
    Regards,
    Gaurav

    Nops
    It doesn't work.
    Let me reframe my issue again:
    I dragged country object on my report.
    UK
    US
    JAPAN
    CANADA
    Now lets say in the report title, I write the formula as =Count(country)
    It will give me 4.
    Now I clicked on the column country and applied filter i.e. country = US ; UK
    Now the block shows
    UK
    US
    In the header the cell still shows 4, which I want to see as 2.
    Any ideas....?
    Thanks
    Gaurav

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • I need a function that will go through and encrypt all the strings

    I want to use one way enryption and need a function that will
    go through and encrypt all the strings in my password column in sql
    server 2003.
    I also need a function that compares a test password string
    is equal to the hash value in the database. Can anyone give me some
    advice in this?

    Apparently it's not as simple as I thought. My first instinct
    was
    update yourtable set password = '#hash(password)#'
    but that will crash
    This is inefficient, but you only have to do it once.
    query1
    select id, password thepassword
    from yourtable
    cfloop query="query1"
    update yourtable
    set password = '#hash(thepassword)#'
    where id = #id#

  • Count of rows from different tables.

    Hi Friends,
    I have 4 tables with a common column name "ID". I would like to get the count of rows from all the four tables which has the same ID.
    Ex
    select count(a.id) from table1 a,table2 b,table3 c,table4 d where a.id=b.id=c.id=d.id=5;
    please suggest me some solution

    may be thsi?
    select count(a.id) from table1 a,table2 b,table3 c,table4 d
    where a.id=b.id and a.id=c.id and a.id=d.id and a.id=5;

  • 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,
    Mummy

    Hi,
    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

  • Prevent user from deleting rows from all tables in his own schema

    Hi,
    How can I prevent user from deleting rows in all tables in his own schema.
    I want the user to not able to delete rows from any existing or new tables that might be added in the future.
    The user does not have the "DELETE ANY TABLE" system privilege.
    Please advise.
    Thanks.

    Nowadays, I'd also avoid triggers (if possible).
    Sometimes, when I daydream, I'm rewriting a few applications that I've contributed to as a newbie, and I'm very ashamed of it nowadays.
    From what I've experienced, in retrospective, the emphasis on teaching 'Oracle stuff' has been lying far too much on PL/SQL row-by-row oriented processing instead of letting Oracle 'crunch' sets at once.
    Most of my debugging hours ended up in discovering one or more database triggers 'doing stuff automagically'.
    Another nice blogpost: http://rwijk.blogspot.com/2007/09/database-triggers-are-evil.html
    Regarding OP's question:
    I would just rethink/reconsider this requirement completely.
    Correctly implementing privileges and roles seems the best way to go, yes.
    Triggers? Nah...
    pre-post-edit, noticed thread got updated just before posting
    Don't know what you mean with 'namedropping', but I think it's legitimate to point other readers to interesting Oracle related opinions/articles that do have a technical background and lots of interesting examples.
    post dreaded OTN outage edit (from here)
    Again: I would just rethink/reconsider this requirement completely.
    Both trigger/vpd are being used to hide a design flaw here.

  • Program (PL/SQL) for count the registers of all tables in a schema

    Hi...
    I create a little program , for count the registers of all tables in the schema...
    If you need , send me your email...
    Atte
    Hector

    Hi,
    You can create a script by yourself by executing the script mentioned below:
    Connect as sys or system....
    SQL> spool test.sql
    SQL> select 'select count(*) from '||owner||'.'||table_name||';' from dba_tables;
    SQL> spool off;
    Hope this helps.
    Regards,
    -Praveen.
    http://myracle.wordpress.com

  • Count all rows in all tables

    Is there any easy way to count all of the rows in all of the tables?
    I am currently generating a list of tables by selecting from all_tables and then turning that into individual select count(*) statements using awk.
    I'm guessing there is probably some other better method?

    Jim,
    I have a sql script which I call numrows that will dynamically create select count(*) statements from the dba_tables dictionary view... It does not display all of the tables in the entire database, but instead prompts you for a particular schema. Maybe you can adjust to do what you want it to..
    Regards,
    David
    +++beginning of script
    -- Script to count the number of rows in tables
    set serveroutput on
    declare
    numrows integer;
    cursor c1 is select table_name from user_tables order by table_name;
    function rowcount(tablename in user_tables.table_name%type)
    return integer is
    cursornum integer;
    numrows integer;
    ignore integer;
    begin
    cursornum := dbms_sql.open_cursor;
    dbms_sql.parse(cursornum,
    'select count(*) from ' &#0124; &#0124; tablename,
    dbms_sql.v7);
    dbms_sql.define_column(cursornum, 1, numrows);
    ignore := dbms_sql.execute(cursornum);
    ignore := dbms_sql.fetch_rows(cursornum);
    dbms_sql.column_value(cursornum, 1, numrows);
    dbms_sql.close_cursor(cursornum);
    return numrows;
    end;
    begin
    dbms_output.enable(10000);
    dbms_output.put_line('Table Rows ');
    dbms_output.put_line('------------------------------ ----------');
    for c1rec in c1 loop
    numrows := rowcount(c1rec.table_name);
    dbms_output.put_line(rpad(c1rec.table_name, 32) &#0124; &#0124; numrows);
    end loop;
    end;
    null

  • Need to send text string to new row in expandable table

    I have a table that is a summary of other choices made throughout the document.  For specific check boxes in the form, there is a defined phrase that needs to be sent to a new row in the summary table.
    The general idea is that for checkbox:
    form1.sfMain.sfContent.tableC2.Row1.cbC2b6
    if (this.rawValue == "1") {
    this.resolveNode('form1.sfApp6.tableApp6A._Row1').addInstance(1);
    this.resolveNode("form1.sfApp6.tableApp6A.Row1[*].ddApp6A1c").rawValue = "Blue bottle";
    This needs to be something I can specify for each applicable checkbox (each will have a different text string), but I don't know what the final count is going to be (depends on choices made by the user) so I can't delete rows in the table and start over every time.  It needs to be additive.
    Any suggestions?
    Message was edited by: cyndilynnrose

    For anyone needing the same thing, I found exactly what I needed:
    http://www.truetechtroubleshooting.com/2012/02/advanced-expanding-tables-and-script.html
    The hardest part of getting it working was figuring out how many parent levels I needed to add since I have a heavily layered form.

  • 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

  • Get the count of rows in a table control

    Hi Experts,
      How do I get the count of the rows in a table control during run time.
    I am developing a BDC in which I have to check all entries in a table control.
    My requirement is to get the total number of rows in a table control dynamically.
    Thanks
    Kumar

    Hi,
    Use a variable when u r passing the records from the internal table to the screen fields
    and display the same.
    I think this idea may help u.
    And pls explain me ur requirement clearly.
    Refer to the following link this may help u.
    http://sapabapnotes.blogspot.com/2008/03/working-with-ecatt-extended-computer.html
    Reward if helpful.
    Jagadish

Maybe you are looking for