Count all Tables

Hi all

11.2.0.1
OEL 6.4

I want to count all the tables in our database to check that it is growing. (Well not really fast) ;)

Some helpful Samaritan post me this pl/sql program:
SQL> create table temptable (owner varchar2(30), table_name varchar2(30), row_co                      unt number, record_date date);

Table created.

SQL> declare
  2  counter number;
  3  cursor cur is select owner, table_name from dba_tables;
  4  begin
  5  for rec in cur loop
  6  execute immediate 'select count(*)  from '||rec.owner||'.'||rec.table_name                       into counter;
  7  insert into temptable values (rec.owner,rec.table_name,counter,sysdate);
commit;
  8    9  counter := 0;
 10  end loop;
 11   end;
/ 12
declare
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at line 6
I am already logged in as SYSTEM. :(



If I use "SYS" I get different error.
SQL> declare
  2  counter number;
  3  cursor cur is select owner, table_name from dba_tables;
  4  begin
  5  for rec in cur loop
  6  execute immediate 'select count(*)  from '||rec.owner||'.'||rec.table_name into counter;
  7  insert into temptable values (rec.owner,rec.table_name,counter,sysdate);
  8  commit;
  9  counter := 0;
 10  end loop;
 end;
 11   12  /
declare
*
ERROR at line 1:
ORA-00911: invalid character
ORA-06512: at line 6
Thank you very much
zxy

Published by: yxes2013 on 23.4.2013 18:34

Hello

He ran for me as SYS:

declare
      counter     number;
      cursor cur is select  owner
                         ,          table_name
              from    dba_tables
              WHERE   NVL (iot_type, '?')     != 'IOT_OVERFLOW';
      sql_txt     VARCHAR2 (200);
  begin
      for rec in cur loop
             sql_txt := 'select count(*)  from "' || rec.owner || '"."' || rec.table_name || '"';
--       dbms_output.put_line (sql_txt || ' = sql_txt');
          execute immediate  sql_txt   into counter;
          insert into temptable values (rec.owner,rec.table_name,counter,sysdate);
         commit;
         counter := 0;
     end loop;
end;
/

There are some good questions above about this is a really smart thing to do. If it provides useful information and doesn't hurt too much of the performance of the system, that's fine; Otherwise, look for ways to identify the tables that you are most interested and only them, control by using the auditing tools provided by Oracle if possible. General database discussion forum may be a better place to ask how to do this.

Tags: Database

Similar Questions

  • count all the columns in the tables belonged to the user

    I want to get a handle on the width of the collar of ALL tables owned by a user.
    I have this syntax to check individual tables:
    SELECT COUNT (*)
    Of user_tab_columns
    WHERE table_name = < tbl_name >;

    But, I did a DESC on the USER_TAB_COLUMNS and it is not an owner\user that I can use to get all the tbls.

    Any suggestions how I can get it to go through all the tables (I will be rolled up the output to a file)

    Hello

    USER_TAB_COLUMNS view is not the owner because all available information is on your own schema.

    The DBA_TAB_COLUMNS view has the same information more OWNER. Then, you can query the number of columns for each table of any user. For example:

    SELECT TABLE_NAME, COUNT(*)
    FROM DBA_TAB_COLUMNS
    WHERE OWNER = 'SCOTT'
    GROUP BY TABLE_NAME
    

    Or, for all schemas

    SELECT OWNER, TABLE_NAME, COUNT(*)
    FROM DBA_TAB_COLUMNS
    GROUP BY OWNER, TABLE_NAME
    ORDER BY OWNER, TABLE_NAME
    

    Kind regards
    Miguel

  • How to search all columns of all tables in a database

    I need to search all columns of all tables in a database, I already write the code below, but I got the below error message when running this script


    DECLARE
    The CNT number;
    v_data VARCHAR2 (20);
    BEGIN
    v_data: = "5C4CA98EAC4C";
    FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner = 'admin' and DATA_TYPE = 'VARCHAR2') LOOP
    RUN IMMEDIATELY "SELECT COUNT (*) FROM" | T1.table_name | 'WHERE ' | T1.column_name | ' =: 1' IN cnt USING v_data;
    IF cnt > 0 THEN
    dbms_output.put_line (t1.table_name |) » '|| T1.column_name | | » '|| CNT);
    END IF;
    END LOOP;
    END;
    /



    Error report:
    ORA-00933: SQL not correctly completed command.
    ORA-06512: at line 7
    00933 00000 - "not correctly completed SQL command.
    * Cause:
    * Action:


    Any help please

    If you are running this as a different user than the ADMIN you will also need to add the schema name.

    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.owner||'.'||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
    

    The error could be any strange names of tables or columns. For example, if they contain spaces in the name.
    If you have names, then all identifieres must be placed in "."

    + untested example +.
    {code}
    RUN IMMEDIATELY "SELECT COUNT (*) FROM" ' | "" T1. Owner: ' ». » ' || T1.table_name | " » OÙ « ' || T1.column_name | "" =: 1' IN cnt USING v_data;
    {code}

  • Find the name of the column in all tables

    How to find the name of the column in all tables in the database for any column to reveal the name of the person?


    We have over 1000 tables looking for.and in some places, the name column FNAME LNAME, First_NAME, DNAME

    For example we have Customer table, Table EMPLOYEE and the ORDER Table

    --------------------------------

    Customer table
    --------------------------------

    LNMAE

    EMPLOYEE table

    EMP_ID
    DEPT_NAME (we don't want this column as it is not a name column)
    Last_name (he must propose this column because it is named)

    ----------------------------

    CONTROL Panel

    -----------------------------

    ORDER_ID
    ORDER_NAME (we don't want this column as it is not a name column)
    Last_name (he must propose this column because it is named)

    -------------------------

    Dept table

    -------------------------

    Dept_ID
    DEPT_NAME (we don't want this column as it is not a name column)

    Please advise...

    Thank you.

    Hello

    What exactly do you do?

    If you want to display the tables containing these columns, you can query the view data dictionary USER_TAB_COLS (or ALL_TAB_COLS, or, if you have privileges, DBA_TAB_COLS).

    For example:

    SELECT table_name, column_name

    Of user_tab_cols

    WHERE nom_de_colonne IN ('DNAME', 'FNAME', 'FIRST_NAME', 'LAST_NAME', 'LNAME') - or else

    ORDER BY table_name, column_name

    ;

  • How to find all tables without Unique constraints

    How can I write a design rule that lists all tables with no UKs on them?

    Hello Kent,

    Try this

    function checkUKs(table){
    ruleMessage="";
    if(table.getUKeys().size() == 0){
      ruleMessage="no UKs";
      errType="Problem:";
      return false;
    } else {
      return true;
    }
    }
    checkUKs(table);
    
  • Get the latest date DML for all tables

    Hi gurus,

    Version - ORacle 11i

    I need to get a list of the tables that was not 'DML used' for a long time (updates/Inserts / (and selects too if available)). I searched for this in the forum and found 3 methods I used

    1 insert/update dtm
    ----------------------------------
      SELECT DISTINCT table_name, T.COLUMN_NAME
        FROM all_tab_cols t
       WHERE UPPER (T.COLUMN_NAME) LIKE 'UPD%'
             OR    UPPER (T.COLUMN_NAME) LIKE 'INSERT%'
               AND T.OWNER = 'STG'
               AND T.DATA_TYPE IN ('TIMESTAMP', 'DATE')
    ORDER BY column_name
    
    Issue- Not all the tables have inaert/upd dtm
    2 all_tab_modifications
    -------------------------------------
      SELECT table_Name, timestamp
        FROM all_tab_modifications t
       WHERE T.TABLE_OWNER = 'STG'
    ORDER BY timestamp ASC
    
    Issue - Not all tables are monitored
    3 ORA_ROWSCN
    ------------------------------------------
    select MAX(ORA_ROWSCN), SCN_TO_TIMESTAMP(MAX(ORA_ROWSCN)) from stg.XXXXXX
    
    Issue- This throws error MAX(ORA_ROWSCN) is not a valid input . ie for really old tables this throws error.
    How do I get there?

    Thank you
    S

    957793 wrote:
    Thank you peter.

    But one thing I noticed, sometimes at the time where I start an analysis table calculates statistics, the table disappears from the all_tab_modifications

    Thank you
    S

    Yes, makes the Act of analyzing a table disappears from the view of xxx_tab_modifications. It is because this view follows changes in the analyzed table have been modified in order to analyze the self employment can tell whether or not it must be analused "today."

    Assuming that you use more or less the default policy analysis that Oracle puts in place, it would be a pretty safe assumption that any which table not in xxx_tab_modifications had to be a substantial (as defined by the auto scan parameters) activity dml recently, or in other words did not have an important activity for a long time. You can make a difference based on the last_analyzed_date column in the xxx_tables view.

    John

  • How to add a ROWDEPENDENCIES in all tables in a diagram

    Hello!

    I want to add ROWDEPENDENCIES in all tables to manage the issue of concurrency.

    Please tel me how to add in all the tables of a schema.

    Yours sincerely

    I guess the OP wants to use the information in the rowdependency to drive a model of optimistic locking?

  • Export all tables of database in CSV

    I use Oracle 10 g Release 2

    I need to export all tables of database on an oracle schema to it's corrosponding to the CSV files.

    Can I use 'EXP U_name/pswd GRANTS = Y TABLES = (table_A, table_B, table_C)'. ?

    All advice is a plus.
    Thanks in advance
    Jay

    PL post OS and database versions.

    If you have access to run the export to database utilities, and then use the parameter TABLES as you pointed

    exp - http://docs.oracle.com/cd/E11882_01/server.112/e22490/original_export.htm#sthref1927
    expdp - http://docs.oracle.com/cd/E11882_01/server.112/e22490/dp_export.htm#sthref135

    HTH
    Srini

  • To delete all tables in TT, how can I use cursor this way Timesten 11?

    Hello
    I want to delete all tables in Timesten, so I create a procedure like this, but it seems does not work correctly.

    It seems cursor in not accurate Timesten with which in ORACLE. So we are looking for alternatives to do. Could you please provide your expert voice on it.

    Thank you very much.

    Like the following:


    Command > create or replace procedure dropAllTables
    > as
    > CURSOR mycursor IS select table_name from user_tables;
    > table_name user_tables.table_name%type;
    > dropSql varchar2 (200);
    > start
    > Open mycursor;
    > fetch mycursor into table_name;
    > while mycursor found %
    > loop
    > dropSql: = 'drop table ' | table_name;
    > immediately execute dropSql;
    > fetch mycursor into table_name;
    > end of loop;
    > close mycursor;
    > end;
    > /.

    Created procedure.

    Command > exec dropAllTables;


    8507: ORA-01001: Invalid cursor
    8507: ORA-06512: at "TT. DROPALLTABLES', line 13
    8507: ORA-06512: at line 1
    The command failed.



    How can I use cursor this way Timesten 11?

    It is the implementation of cursor close commit on in Timesten is the cause.

    As the drop statements are internally auto-valider the transaction so it closes the cursor itself. So when the next time that you attempt to extract it is your "error cursor not valid."

    Can you try this instead

    create or replace procedure dropAllTables
    as
    CURSOR mycursor IS select table_name from user_tables;
    table-name user_tables.table_name%type;
    type t_row_collection is table of the directory index user_tables.table_name%type;
    t_rows t_row_collection;
    dropSql varchar2 (200);
    Start
    Open mycursor;
    Mycursor fetch bulk collect into t_rows;
    Close mycursor;
    j in t_rows.first... loop t_rows. Last
    dropSql: = 'drop table ' | t_rows (j);
    immediately run dropSql;
    end loop;
    end;

  • How FLASHBACK all TABLEs and indexes in a certain pattern for a restoration of p?

    Today I read a few web pages on how to use FLASHBACK to restore to a Restore Point.

    Unfortunately, all of these examples show just how to restore a single TABLE for example

    FLASHBACK TABLE t to RESTORE POINT before_we_do_anything;

    But how can I FLASHBACK all TABLEs (and indexes and other dependent objects) in a certain pattern to a one-step restore point)?

    FLASHBACK myschema.* to before_we_do_anything POINT of RESTORATION;

    does not work.

    Peter

    There is nothing like that. However, you could flashback the entire database to a point in time. It would of course have implications through patterns all the good.

    Nicolas.

  • How to delete all TABLEs in the schema SYS that are created from 09:15?

    Unfortunately a script created a lot of tables in the diagram (= SYS) and bad Tablespace (= SYSTEM).

    How can I delete all TABLES that are created inTablespace = SYSTEM and SCHEMA = SYS (in a DDL command)
    respectively for the past 3 hours from 09:15 to 25 Sep 2011?

    Alternative: How can I move these tables in another schema (for example ATEST) and Tablespace (USERS)?
    Is this possible with Oracle XE or Oracle Enterprise?

    Peter

    You can use ALTER TABLE... MOVE. It offers a TABLESPACE clause, which allows you to choose a different tablespace as target. Refer to the documentation for your version of the database.

  • How to convert * all * tables of text in a document?

    Version: Indesign CS 5.5

    I have a massive document that was given to me after be imported into Word, and the person who has imported, it did not convert tables to text (or they tried and it did not work, be it, I have a huge amount of tables that must be not filed).

    I am responsible for the document formatting, and the formatting requirements are to convert all tables in the text document. I was able to batch-process other formatted in the document with the help of find + replace, but I can't seem to find a way to search for all instances of a table in the document and convert all the table set in shape to the text. I can find every table in the search/replace tool using < 0016 >, but I have no idea how, and then delete the table set shaped with the change function.

    I have no text special requirements (standard; tabs for columns and new paragraphs for the lines) and all tables should be converted, regardless of their formatting or content, so it's fairly simple formatting.

    There must be SOME way tot automate this process, it seems incredibly Loïc having to select each table individually and go up to the menu to select "convert table to text... '. ». Any idea is appreciated.

    Click on the text cursor in your text running, and then run this Javascript. WARNING: fully typed memory!

    App.Selection [0].parentStory.tables.everyItem () .convertToText ();

  • Get the DDL for all tables in a schema;

    Hello

    I tried to get the DDL for all tables under my own diagram "A". Here are the steps I've tried, but in vain I
     1. logged in as a user A 
    2. And the ran query 
              
    SELECT DBMS_METADATA.get_ddl ('TABLE', 'XYZ')
    FROM user_tables
          
    o/p
    (HugecloB)
    
    {code}
    
    Any idea how i can get the DDL for all the tables under my own schema ?
    
    
    Thank you so much!
    
    Edited by: user642297 on Feb 4, 2011 12:05 PM
    
    Edited by: user642297 on Feb 4, 2011 12:05 PM
    
    Edited by: user642297 on Feb 4, 2011 12:05 PM
    
    Edited by: user642297 on Feb 4, 2011 12:07 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    Your idea is good, you missed only to use the correct table name:

    SELECT DBMS_METADATA.get_ddl ('TABLE', table_name)
    FROM user_tables;
    

    Concerning

  • Apply a table style to all tables in the document

    I can't find a way to apply certain style of table for all tables in a document of p. 200.

    Specifically, clear any formatting within the cells (cell and replacements styles) would be a plus. All tables must have a unique look with a header cell style preset and style of cell in the body properly defined by a table style.

    All, even partial-help tips will be appreciated because they can save me time.

    I can't believe there is no way to do as other more complicated things are possible using find it & change don't function, for example objects, GREP, you name it.

    Roman

    This javascript will apply the table Style "tabs" to all the tables in the entire document and removes the replacements the (I'm not sure that this will happen automatically when you apply a table style). You set the header & body styles in the style of your table, and they should be applied automatically.

    for (s=0; s
    
    Copy, paste into a text editor (Notepad; TextEdit in plain text mode. best is the editor ESTK delivered installed with InDesign). Save as "ApplyTableStyles.jsx" in your own folder User Scripts, and it will appear in the Scripts panel. Double-click it to run it, and then sit down and relax.
  • How to apply an overall style to all tables in RoboHelp 8?

    Is it possible to apply a style to table for all tables in a RoboHelp 8 project without doing table-by-table?

    Indeed a nice feature, missed that one, thanks.

    It seems that there is a limit, however, you cannot apply an overall style to table, line of the table, colum or cell in the Styles dialog box. It seems that the truly global application of a style to all classes of paintings at a time, is to add the definition of every single table in the Styles dialog box. It seems to me that you can only apply real global styles by changing the CSS directly.

    Take a bow

    Willam

Maybe you are looking for

  • create dvd windows El programa no works in mi pc

    Al open el programa dvd creation don't is abre me video of the k targeta say not to encuentra

  • On service packs

    I have Win XP 5.1 with service pack 3. I tried to watch Netflix, but I was told that I need service pack 2. I can't install 2?

  • Unable to connect to other PC and installed protocols are empty

    Original title: serious problems of networking on Vista w / Atheros AR5007EG wireless card Hello I have a laptop Acer Extenza 5620ZG running Windows Vista 32-bit and have serious problems of networking. In this laptop's wireless card is an Atheros AR

  • QUERY CONTACTS

    I have a lot of contacts that I have to constantly - but individually by e-mail. When I hold in the start menu of n in name of the person "regularly" 'CREATE a MESSAGE' box, it is not automatically enter; I have to go to the CONTACT, click on the nam

  • Windows DVD Maker-burned a video DVD reads with no sound

    Windows DVD Maker video playback errors I'm doing a movie on dvd, this used to before, but now what is happening that the sound is ok on video before I burn it but when I burned video disc has not all the sounds that it but image is perfect. When I p