Table_name  +  number of records

i need to make a listing that give me all tables that i own and beside the number of records in each table i have
like :
table aaa 32 records
table bbb 962 records..
i have large number of tables
can anybody help?
thank you

- Do you need an exact count? Or an approximate count?
- Do you use the CBO or the RBO?
If you use the CBO and can tolerate an approximate count,
SELECT table_name, num_rows
  FROM user_tablesOtherwise, you'd need to use dynamic SQL. This will be quite expensive, since it involves full-scanning every table in the database
DECLARE
  l_cnt NUMBER;
BEGIN
  FOR x IN (SELECT * FROM user_tables)
  LOOP
    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || x.table_name INTO l_cnt;
    dbms_output.put_line( x.table_name || ' ' || l_cnt );
  END LOOP;
END;Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • How to get number of records in all user tables in one select

    Please advise how to retrieve the number of records in all user tables in one select. I would likt to extract the data to excel file.
    Many thanks,
    Andrew

    You could always analyze the tables:
    declare
    begin
      for X in (select owner, table_name from all_tables
                 minus
                select owner, table_name from all_external_tables) LOOP
          dbms_stats.Gather_Table_Stats(X.Owner, X.Table_Name) ;
      end loop;
    end;
    /Then: Select Owner, Table_Name, Num_Rows from All_Tables ;

  • Number of records in each partition

    Hi,
    Can any one please tell me, how to display number of record in each partion in any table.
    I wanted to use following in PL/SQL but it gives me error.
    Declare
    Cursor c1 is
    select partition_name into part_name from all_tab_partition where table_name = 'table_name';
    BEGIN
    for rec in c1
    Loop
    select count(*) into temp_var from table_name partition(rec.part_name)
    END LOOP;
    END;
    I guess I need dynamic SQL ..
    Any thoughts on this ??
    Thanks,
    Av

    It is always better to analyze the tables and get these details from num_rows as mentioned before but just in case you want the latest information from the table dynamically then use the following
    Declare
    Cursor c1 is
    select table_name,partition_name from all_tab_partitions where table_name = 'SALESDETAILS';
    v_sql varchar2(2000);
    temp_var number:=0;
    BEGIN
    for rec in c1
    Loop
    execute immediate 'select count(*) from '||rec.table_name||' partition('||rec.partition_name||')' into temp_var;
    dbms_output.put_line('The Partition '||rec.partition_name||' of table '||rec.table_name||' has '||temp_var||' rows');
    END LOOP;
    END;

  • How  to retrieve one row from the number of records in a table

    i want to retrieve the rows from the number of records in a table without using the perticular column name.

    select count(*) from table
    /If you have your table currently analyzed, and no changes have been made, then you could
    select num_rows from user_tables where table_name = 'table'

  • Forms: how to use COUNT_RECORD to get the number of record retrieved?

    After GO_BLOCK(BlockName)EXECUTE_QUERY, there must a way to obtain the number of records retrieved.
    I like to use this number to display to number of records on the form.
    Clearly, a not so good way is:
    SELECT COUNT(*) INTO :NUM_RECORD FROM Table_Name;
    It queries table one more time.
    Could any one give a clue?
    Thank you.

    Dear Kiran,
    Fom tables EINE (inforec no, plant) and EINA (inforec no, material, vendor), you can get the desired information.
    Regards,
    Prasanth

  • Total number of record in database??

    Hi,
    How to find total number of record in database using Single Query/Statement?
    Thanks

    Here we go, in a Single Statement Block
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2    v_cnt NUMBER := 0;
      3    v_tot NUMBER := 0;
      4    CURSOR cur_tables IS
      5      SELECT table_name FROM user_tables;
      6  BEGIN
      7    DBMS_OUTPUT.ENABLE(1000000);
      8    FOR t IN cur_tables
      9    LOOP
    10      EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM '||t.table_name INTO v_cnt;
    11      v_tot := v_tot + v_cnt;
    12    END LOOP;
    13    DBMS_OUTPUT.PUT_LINE('Total Table Rows: '||v_tot);
    14* END;
    SQL> /
    Total Table Rows: 5850553
    PL/SQL procedure successfully completed.
    SQL>What use it is is anybody's guess.
    Note: This only works on the users own tables, not all the system tables or tables from other schemas in the database.

  • How to find the number of records per months  in cube

    Hi,
      how to find the number of records per months for my all cubes?
      Can i use the ListCube transaction to find totl number f records per cube monthwise ?
    Jimmy

    Hi,
    Here is a program to generate no of records and list of ODS and Cubes in Active version.Schedule this program in background and create a cube to load this information and schedule to the data from the file generated by the program. Schedule this all per you requirement.
    1.Copy the code into your Z<programname> from Se38.
    2.change the FILENAME in CALL FUNCTION 'GUI_DOWNLOAD' in the program to the location from where you can pick the information to load data to cube(eg Application server).
    3.Save program.
    4.Schedule the program in background as required
    5.Create cube with infoobjects to hold no of records and Infoprovider name
    6.Load this cube based on event after the program job is done.
    Hence you can report on this cube to see no of records in  CUBE or ODS in your box.
    Please find the code below.
    Cheers,
    Kavitha Kamesh.
    types: begin of itabs ,
          tabname type dd02l-tabname,
          end of itabs.
    data: itab type itabs occurs 0 with header line.
    data: counter type i.
    data: begin of itab1 occurs 0,
    tabname type dd02l-tabname,
    counter type i,
    end of itab1.
    DATA: ITABTABNAME TYPE STRING.
    DATA: LENGTH TYPE I.
    DATA: OBJECT(30).
    data: str(6) type c.
    select  tabname from dd02l into table itab where ( tabname LIKE  '/BIC/F%' or tabname LIKE  '/BIC/A%00' )
    and TABCLASS = 'TRANSP' and AS4LOCAL = 'A'.
    loop at itab.
      select count(*) from (itab-tabname) into counter.
      str = itab-tabname.
      if str = '/BIC/F'.
    LENGTH  = STRLEN( ITAB-TABNAME ).
      SHIFT  itab-tabname BY 6 PLACES LEFT.
    ELSEIf  str = '/BIC/A'.
      SHIFT  itab-tabname BY 6 PLACES LEFT.
      LENGTH  = STRLEN( ITAB-TABNAME ).
    LENGTH = LENGTH - 2.
    endif.
      itab1-tabname = itab-tabname(LENGTH).
      append itab1.
      itab1-counter = counter.
      clear itab-tabname.
      clear:  COUNTER.
    endloop.
    *********** itab1
    loop at itab1.
    write:/ itab1-tabname, itab1-counter.
    endloop.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                    =
        FILENAME                        = 'c:records.xls'
        FILETYPE                        = 'ASC'
    *   APPEND                          = ' '
        WRITE_FIELD_SEPARATOR           = ','
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    * IMPORTING
    *   FILELENGTH                      =
      TABLES
        DATA_TAB                        = itab1
    *   FIELDNAMES                      =
    * EXCEPTIONS
    *   FILE_WRITE_ERROR                = 1
    *   NO_BATCH                        = 2
    *   GUI_REFUSE_FILETRANSFER         = 3
    *   INVALID_TYPE                    = 4
    *   NO_AUTHORITY                    = 5
    *   UNKNOWN_ERROR                   = 6
    *   HEADER_NOT_ALLOWED              = 7
    *   SEPARATOR_NOT_ALLOWED           = 8
    *   FILESIZE_NOT_ALLOWED            = 9
    *   HEADER_TOO_LONG                 = 10
    *   DP_ERROR_CREATE                 = 11
    *   DP_ERROR_SEND                   = 12
    *   DP_ERROR_WRITE                  = 13
    *   UNKNOWN_DP_ERROR                = 14
    *   ACCESS_DENIED                   = 15
    *   DP_OUT_OF_MEMORY                = 16
    *   DISK_FULL                       = 17
    *   DP_TIMEOUT                      = 18
    *   FILE_NOT_FOUND                  = 19
    *   DATAPROVIDER_EXCEPTION          = 20
    *   CONTROL_FLUSH_ERROR             = 21
    *   OTHERS                          = 22
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  • How to find the number of records in ods?

    how to find the number of records in ods?
    Pls suggest the solution apart going to the table of ods and seeing the number of records.
    Is there any program or function module to see the number of records in ods?
    For eg: SAP_INFOCUBE_DESIGNS is a program which gives the detail (number of records) of infocube.

    Hi,
    I was looking at this and found the following tables that may be of help.
    One of these tables will include a summary of the record count of all the tables in your system based on the last time each table had it's database statistics calculated:
    DBSTATTADA
    DBSTATTDB2
    DBSTATTDB4
    DBSTATTDB6
    DBSTATTINF
    DBSTATTMSS
    DBSTATTORA
    We run on an Oracle database so the table record counts can be taken from DBSTATTORA. Type in AZ in table selection field in SE16 to restrict the output to ODS (or DSO) tables only.
    The record count is at the time indicated in the timestamp field. Obviously this is not real time but should not be too out of date - if it is you may be having performance issues and should get your DBA / Basis to run a full refresh of DB stats.
    Hope this helps, alhtough not real time the table should give you a decent indication of the size of all your ODS objects (or any other table for that matter!)

  • Which system field returns the number of records returned after a select?

    Which system field returns the number of records returned after a select?
    a) sy-index
    b) sy-recno
    c) sy-lncnt
    d) sy-dbcnt
    e) sy-tabix

    Hi,
       SY-DBCNT
    Regards,
    Prashant

  • SQL help: return number of records for each day of last month.

    Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
    Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
    Thanks
    Ray

    Peter: thanks. That helps but not completely.
    When I run the query to include only records for July using a statement such as following
    ============
    SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
    FROM EVENT_DATA ED
    WHERE AGENT_ID = 160
    AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
    GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
    ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
    =============
    I get the following
    COUNT(ED.UTIMESTAMP) DATA
    1 07/20
    1 07/21
    1 07/24
    2 07/25
    2 07/27
    2 07/28
    2 07/29
    1 07/30
    2 07/31
    Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
    Thanks
    Ray

  • Hw to find total number of records

    Hi All,
    Can anyone help from these
    1. how to find total number of reports for a particular cube/ods... need step - step solution
    2. how to find total number of records for a particular Cube and ODS and Aggr's to till date.
    3.what is sandbox,mirror sys,instance of a sys..?
    4.what r TWS(Tivoli Workload Scheduler) jobs? how these r different to standard schedulers?
    Thanks in ADv
    Linda

    Hello Linda,
    As you have lots of answers on first 2 so i'll start from 3rd onward.
    3. Sandbox is mostly practice system where you can do all kind of R&D, mirror sys can be mirror image of any system depends on the organization and instance of system is again mirror image of one system.
    4. TWS is third party tool for scheduling which doesn't come along with SAP like standard scheduler as TWS has been prepared specially for this purpose so it has some more features than standard.
    Hope it helps.
    San.

  • How to find total number of records in a BDoc?

    Dear all,
    I have replicated about BP 1088 records from ISU into CRM system with block size 100. Technically on SMW01, for each successfully processed BDoc, there will be 100 records (corresponds to 100 block size). But due to some failed BDocs, not all "successfully" BDocs will have 100 records each, some may have only 1 record inside...or 30...or 88 for example. So, may i know how to find or is there a report i can look into to find the total number of records clearly shown for each of the successfully processed green status BDocs???
    Please help and points will be rewards!!
    Thank You
    Best Regards,
    CK

    I am just showing this to show how to get the rowcount along with the cursor, if the program has so much gap of between verifying the count(*) and opening the cursor.
    Justin actually covered this, he said, oracle has to spend some resources to build this functionality. As it is not most often required, it does not makes much sence to see it as a built-in feature. However, if we must see the rowcount when we open the cursor, here is a way, but it is little bit expensive.
    SQL> create table emp_crap as select * from emp where 1 = 2;
    Table created.
    SQL> declare
      2   v_cnt     number := 0;
      3   zero_rows         exception;
      4  begin
      5    for rec in (select * from (select rownum rn, e.ename from emp_crap e) order by 1 desc)
      6     loop
      7        if v_cnt = 0 then
      8           v_cnt := rec.rn;
      9        end if;
    10     end loop;
    11     if v_cnt = 0 then
    12        raise zero_rows;
    13     end if;
    14   exception
    15    when zero_rows then
    16      dbms_output.put_line('No rows');
    17   end;
    18  /
    No rows
    PL/SQL procedure successfully completed.
    -- Now, let us use the table, which has the data
    SQL> declare
      2   v_cnt     number := 0;
      3   zero_rows         exception;
      4  begin
      5    for rec in (select * from
      6          (select rownum rn, e.ename from emp e)
      7          order by 1 desc)
      8     loop
      9        if v_cnt = 0 then
    10           v_cnt := rec.rn;
    11           dbms_output.put_line(v_cnt);
    12        end if;
    13     end loop;
    14     if v_cnt = 0 then
    15        raise zero_rows;
    16     end if;
    17   exception
    18    when zero_rows then
    19      dbms_output.put_line('No rows');
    20   end;
    21  /
    14
    PL/SQL procedure successfully completed.Thx,
    Sri

  • How to limit the number of records in WebI Report

    Hi,
    I have a requirement where I need to display the WebI Report data only if the number if record is less than 65k.
    Incase if the records are more than 65k then the report should be blank and a text message needs to be displayed.
    The client dont want to set the number of records either in universe or at the edit query at the report. They want to limit once the report is executed.
    Please let me know if its possible to do it at the report level.
    Thanks in advance!!
    Best Regards
    SAP BO

    Optional prompts are not a problem.
    Assuming you first query uses the following SQL statement
    select a,b,c from t where x=y and z=@prompt(...)
    The query for checking the number of rows should use the following SQL code
    select count(*) from t where x=y and z=@prompt(...)
    The original query should be modified as follows
    select a,b,c from t where x=y and z=@prompt(...) AND (select count(*) from t where x=y and z=@prompt(...)) < 65000
    Regards,
    Stratos

  • CLIENT_TEXT_IO - Hanging on "PUT" for large number of records

    I have successfully used CLIENT_TEXT_IO but my users have run into an error where the Form hangs and spits out details such:
    "oracle.forms.net.HTTPNStream.doFlush"
    etc....
    This happens when the number of records in the datablock is high (ex: 70,000 recs). So my question is: Is there a limit on how many lines you can write to a file?
    I'm just creating a CSV file on the client's machine using CLIENT_TEXT_IO.PUT_LINE. It works fine on say a few thousand recs but after that it hangs.
    I'm on Oracle Application Server 10g, Release 9.0.4 on Windows Server 2003, and forms compiled using Oracle Developer Suite 9.0.4.
    Thanks,
    Gio

    Hello,
    When playing with huge data, it is better to generate the file on the A.S. then get it back to the client.
    <p>Read this article</p>
    Francois

  • Add number of records to a field

    I need to load data in BW ODS from flat file and want to populate one field ROWID which will hold record numbers starting from 1 if ODS is empty. This ROWID in ODS is used as Key field. I want to populate this ROWID based on number of records in flat file.
    If there are already records in ODS and say last record number is 10, next record number will be 11 and will populate rests one by one.
    So first I want to read ODS table if there are any records. If empty, ROWID will be populating from record 1 and if not empty, get the last ROWID and populate from next number.
    Help me with the code please?

    Hi,
    If the select count (*) is successfull then add 1 to the count then move it to the rowid column.
    SELECT COUNT(*) INTO V_COUNT FROM TABLENAME.
    IF SY-SUBRC NE 0.
    * If no records found then set the counter to 1.
      v_count = 1.
    ELSE.
    * If the record is found then set the row id of the table by adding 1.
      TABLENAME-ROWID = V_COUNT + 1.
    ENDIF.
    **If you want to insert multiple records within a loop.
    LOOP AT ITAB.
    * Increment the counter.
      V_COUNT = V_COUNT + 1.
    * Set the row id.
      TABLENAME-ROWID = V_COUNT.
    ENDLOOP.
    Hope this helps.
    Thanks
    Naren

Maybe you are looking for

  • Free of charge Item

    Hai, What is Free of Charge Item ? In which situation we use Free of Charge item? What configuration settings I have to make for this? What is the difference between free of charge Item and Free of charge delivery? Regards, Siva

  • How to deploy adapter module in PI 7.0

    Hi, Can ne one guide me how to deploy adapter mdule in PI 7.0? The XI consultant has given me the EAR file..how do i deploy it?..how do i check it?

  • How can I find and install the state diagram toolkit and how to--

    Hi, I like to do practice how to do coding by using state diagram toolkit. For that purpose I need to install that software. Can you please help me in this regard about how to get theat toolkit and install afterwards? I have another question. By usin

  • Why is iPhoto Library growing?

    The iPhoto library on my iMac has grown from about 6000 pictures to over 26,000!  It seems that many "face thumbnails" have been created although there also seems to be many duplicates. I have never used "Find faces." I have searched all drives and f

  • PSE12 corrupted. Organiser won't launch, corrupted thumbnails etc

    On PSE 12 it seems to have corrupted and I can't seem to fix it. Initially Organiser thumbnails appeared as torn pages, then organiser wouldn't launch at all. I've uninstalled and re installed but it still won't launch organiser and when I try and la