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

Similar Messages

  • Deleting the contents of all tables in a schemas

    hi ,
    can someone tell me if there is a way of deleting the contents of all tables , without dropping any.because the schema is big and just want to empty all tables at the same time.
    thanks in advance.

    Hi,
    >>Will they be enabled after running the script?
    Well, of course they need to be re-enabled ... don't you think?
    SQL> create table a (id number primary key);
    Table created.
    SQL> create table b (id number constraint fk_b_a references a);
    Table created.
    SQL> select constraint_name,status from user_constraints where table_name='B';
    CONSTRAINT_NAME                STATUS
    FK_B_A                         ENABLED
    SQL> truncate table a;
    truncate table a
    ERROR at line 1:
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    SQL> alter table b disable constraint fk_b_a;
    Table altered.
    SQL> truncate table a;
    Table truncated.
    SQL> select constraint_name,status from user_constraints where table_name='B';
    CONSTRAINT_NAME                STATUS
    FK_B_A                         DISABLED
    SQL> alter table b enable constraint fk_b_a;
    Table altered.
    SQL> select constraint_name,status from user_constraints where table_name='B';
    CONSTRAINT_NAME                STATUS
    FK_B_A                         ENABLEDCheers
    Legatti

  • Get the names of all tables

    First I want to tell you: I'm a amateur concerning Java Programming.
    My task is to write a java program - using JCO -, which retrieves the names of all tables (a user can access).
    Can anybody help me, please?

    Hi Michael,
    i can't help you because i don't know anything about JCO!
    It's simply funny and i'm happy to see a "known face" here!
    Perhaps this will help you:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/tips and tricks for sap java connector client programming.pdf
    And don't be so decent...you're not so bad in Java at all
    Greetings
    Florian

  • CTE for Count the Binary Tree nodes

    i have the table structure like this :
    Create table #table(advId int identity(1,1),name nvarchar(100),Mode nvarchar(5),ReferId int )
    insert into #table(name,Mode,ReferId)values('King','L',0)
    insert into #table(name,Mode,ReferId)values('Fisher','L',1)
    insert into #table(name,Mode,ReferId)values('Manasa','R',1)
    insert into #table(name,Mode,ReferId)values('Deekshit','L',2)
    insert into #table(name,Mode,ReferId)values('Sujai','R',2)
    insert into #table(name,Mode,ReferId)values('Fedric','L',3)
    insert into #table(name,Mode,ReferId)values('Bruce','R',3)
    insert into #table(name,Mode,ReferId)values('paul','L',4)
    insert into #table(name,Mode,ReferId)values('walker','R',4)
    insert into #table(name,Mode,ReferId)values('Diesel','L',5)
    insert into #table(name,Mode,ReferId)values('Jas','R',5)
    insert into #table(name,Mode,ReferId)values('Edward','L',6)
    insert into #table(name,Mode,ReferId)values('Lara','R',6)
    select *from #table
    How do i write the CTE for count the Binary tree nodes on level basis. Here is the example,
    now,what i want to do is if i'm going to calculate the Count of the downline nodes.which means i want to calculate for '1' so the resultset which i'm expecting
    count level mode
    1 1 L
    1 1 R
    2 2 L
    2 2 R
    4 3 L
    2 3 R
    How do i acheive this,i have tried this
    with cte (advId,ReferId,mode,Level)
    as
    select advId,ReferId,mode,0 as Level from #table where advid=1
    union all
    select a.advId,a.ReferId,a.mode ,Level+1 from #table as a inner join cte as b on b.advId=a.referId
    select *From cte order by Level
    i hope its clear. Thank you

    See Itzik Ben-Gan examples for the subject
    REATE TABLE Employees
      empid   int         NOT NULL,
      mgrid   int         NULL,
      empname varchar(25) NOT NULL,
      salary  money       NOT NULL,
      CONSTRAINT PK_Employees PRIMARY KEY(empid),
      CONSTRAINT FK_Employees_mgrid_empid
        FOREIGN KEY(mgrid)
        REFERENCES Employees(empid)
    CREATE INDEX idx_nci_mgrid ON Employees(mgrid)
    SET NOCOUNT ON
    INSERT INTO Employees VALUES(1 , NULL, 'Nancy'   , $10000.00)
    INSERT INTO Employees VALUES(2 , 1   , 'Andrew'  , $5000.00)
    INSERT INTO Employees VALUES(3 , 1   , 'Janet'   , $5000.00)
    INSERT INTO Employees VALUES(4 , 1   , 'Margaret', $5000.00) 
    INSERT INTO Employees VALUES(5 , 2   , 'Steven'  , $2500.00)
    INSERT INTO Employees VALUES(6 , 2   , 'Michael' , $2500.00)
    INSERT INTO Employees VALUES(7 , 3   , 'Robert'  , $2500.00)
    INSERT INTO Employees VALUES(8 , 3   , 'Laura'   , $2500.00)
    INSERT INTO Employees VALUES(9 , 3   , 'Ann'     , $2500.00)
    INSERT INTO Employees VALUES(10, 4   , 'Ina'     , $2500.00)
    INSERT INTO Employees VALUES(11, 7   , 'David'   , $2000.00)
    INSERT INTO Employees VALUES(12, 7   , 'Ron'     , $2000.00)
    INSERT INTO Employees VALUES(13, 7   , 'Dan'     , $2000.00)
    INSERT INTO Employees VALUES(14, 11  , 'James'   , $1500.00)
    The first request is probably the most common one:
     returning an employee (for example, Robert whose empid=7) 
    and his/her subordinates in all levels. 
    The following CTE provides a solution to this request:
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      -- Anchor Member (AM)
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 7
      UNION ALL
      -- Recursive Member (RM)
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    Using this level counter you can limit the number of iterations
     in the recursion. For example, the following CTE is used to return 
    all employees who are two levels below Janet:
    WITH EmpCTEJanet(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 3
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTEJanet as M
          ON E.mgrid = M.empid
      WHERE lvl < 2
    SELECT empid, empname
    FROM EmpCTEJanet
    WHERE lvl = 2
    As mentioned earlier, CTEs can refer to
     local variables that are defined within the same batch.
     For example, to make the query more generic, you can use 
    variables instead of constants for employee ID and level:
    DECLARE @empid AS INT, @lvl AS INT
    SET @empid = 3 -- Janet
    SET @lvl   = 2 -- two levels
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = @empid
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
      WHERE lvl < @lvl
    SELECT empid, empname
    FROM EmpCTE
    WHERE lvl = @lvl
    Results generated thus far might be returned (but are not guaranteed to be), 
    and error 530 is generated. You might think of using the MAXRECURSION option 
    to implement the request to return employees who are two levels below 
    Janet using the MAXRECURSION hint instead of the filter in the recursive member
    WITH EmpCTE(empid, empname, mgrid, lvl)
    AS
      SELECT empid, empname, mgrid, 0
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1
      FROM Employees as E
        JOIN EmpCTE as M
          ON E.mgrid = M.empid
    SELECT * FROM EmpCTE
    OPTION (MAXRECURSION 2)
    WITH EmpCTE(empid, empname, mgrid, lvl, sortcol)
    AS
      SELECT empid, empname, mgrid, 0,
        CAST(empid AS VARBINARY(900))
      FROM Employees
      WHERE empid = 1
      UNION ALL
      SELECT E.empid, E.empname, E.mgrid, M.lvl+1,
        CAST(sortcol + CAST(E.empid AS BINARY(4)) AS VARBINARY(900))
      FROM Employees AS E
        JOIN EmpCTE AS M
          ON E.mgrid = M.empid
    SELECT
      REPLICATE(' | ', lvl)
        + '(' + (CAST(empid AS VARCHAR(10))) + ') '
        + empname AS empname
    FROM EmpCTE
    ORDER BY sortcol
    (1) Nancy
     | (2) Andrew
     |  | (5) Steven
     |  | (6) Michael
     | (3) Janet
     |  | (7) Robert
     |  |  | (11) David
     |  |  |  | (14) James
     |  |  | (12) Ron
     |  |  | (13) Dan
     |  | (8) Laura
     |  | (9) Ann
     | (4) Margaret
     |  | (10) Ina
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Hi! I've just installed mountain lion and I find one of the programs I need for my work is crashing all the time. any ideas what i can do?

    hi! I've just installed mountain lion and I find one of the programs I need for my work is crashing all the time. any ideas what i can do?

    Ah!
    Factuur Bright x
    part of errors:
    Process:         Factuur Bright X [1476]
    Path:            /Applications/Factuur Bright X/Factuur Bright X.app/Contents/MacOS/Factuur Bright X
    Identifier:      ???
    Version:         ??? (2.0.0b20)
    Code Type:       X86 (Native)
    Parent Process:  launchd [184]
    User ID:         501
    Date/Time:       2013-07-10 22:35:39.180 +0200
    OS Version:      Mac OS X 10.8.4 (12E55)
    Report Version:  10
    Interval Since Last Report:          2118 sec
    Crashes Since Last Report:           1
    Per-App Interval Since Last Report:  24 sec
    Per-App Crashes Since Last Report:   1
    Anonymous UUID:                      47D641A2-4625-7590-369C-8BAFE1439551
    Crashed Thread:  0  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGBUS)
    Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000010

  • Reports for Count the number of External Candidate Registration - ERecruitment

    Dear Experts
    Anyone know a reports for Count the number of External Candidate Registration - ERecruitment?
    Thanks
    Regards

    http://scn.sap.com/thread/784769 http://scn.sap.com/thread/1625606 read here!

  • Gui_download for transferring the data from internal table to excel sheet.

    hi all,
    i am using gui_download for transferring the data from internal table to excel sheet.
    I have a internal table with 3 columns col1,col2,col3 and I am getting the file at the specified path,but my problem is that,in the excel sheet(path specified) all the 3 columns values are printed in one column.Please help me.
    Thanks in advance.

    Hi Venkata,
    plz use FM 'SAP_CONVERT_TO_XLS_FORMAT' :
      call function 'SAP_CONVERT_TO_XLS_FORMAT'
        exporting
    *   I_FIELD_SEPERATOR          =
    *   I_LINE_HEADER              =
          i_filename                 = p_file
    *   I_APPL_KEEP                = ' '
        tables
          i_tab_sap_data             = t_mbew
    * CHANGING
    *   I_TAB_CONVERTED_DATA       =
    * EXCEPTIONS
    *   CONVERSION_FAILED          = 1
    *   OTHERS                     = 2
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    Hope this helps,
    Erwan

  • How to find the list of existing tables in a schema using DB link?

    Hi
    I know how to find the list of existing tables in a schema using the following query
    SQL> select * from tab;
    but, how to list the tables using a DB link?
    For Example
    SQL> select * from tab@dblink_name;
    why this doesn't work?
    Pl advice me
    Thanks
    Reddy.

    ORA-02019: connection description for remote database not foundHave you used this database link successfully for some other queries?
    The error posted seems to indicate that the DB Link is not functional at all. Has it worked for any other type of DML operation or is this the first time you ever tried to use the link?

  • Newbie ques : How to get the list of all tables in the database

    Hi,
    I'm very new to Oracle (using Oracle8i currently). I wanted to know if there is a way to get the list of all tables in the database. Like in mySQL you can use the command " show tables" to get the list of all the tables.
    Any help will e greatly appreciated. Please "cc" any reply to [email protected] also.
    thanks
    Deven

    Hi
    Select table_name, owner from all_tables;
    will give u all the tables in the database.
    all_tables, dba_tables, user_tables
    all_objects, dba_objects, dba_objects
    there are many, more tables. login as system and query the tab and try to describe the tables.
    Thanks
    Malar

  • Table to get the list of all tables in the database

    hi,
    please let me knwo the table where i can get the list of all tables in the database

    hi,
    please let me knwo the table where i can get the list
    of all tables in the databaseHi Michael,
    Will you EVER start reading some documentation?
    I guess it's not far that many regulars won't reply to those kind of questions.
    Believe me, reading doesn't hurt (well, at least, most of the times).
    Rgds,
    Guido

  • Programming Logic required for pulling the records for past month /week

    Hi All
    I need help in the SQL programming logic.
    Oracle Database Version: 10.2.0.3.0
    Requirement
    In a data warehouse environment, I need to programme for weekly and monthly automated batch jobs to insert the data from Data_tbl to Reporting_tbl for generating reports. Tables descriptions are given below.
    Table1 - Data_tbl (Source table –this table gets updated everyday).
    Record_dt     first_name     last_name
    Table2 - Reporting_tbl_(Target table)
    Cycle_dt     first_name     last_name
    1. Monthly Report
    In the SQL Query, I have where clause condition—
    Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’
    Using the above condition in development, I am pulling the data from source table for the past month data. This will be repeated every month and it should be automated.
    i.e., if I run this report any time in dec 2008, it should pick records of dates from Nov 01st to Nov 30th 2008. if I run this report any time in Jan 2009, it should pick records of dates from Dec 01st to Dec 31st 2008.
    Date Values should be assigned for past month. Value of Cycle_dt in target table should be end date of past month like 30-nov-2008, 31-dec-2008.
    2. Weekly Report
    In the SQL Query, I have where clause condition—
    Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’
    Here week start day is Monday and end day is Sunday.
    If I run the report between Dec 08th to Dec 14th , it should pull records of dates from Dec 01st to Dec 07th 2008.
    On Dec 15th, it should pick from Dec 08th to Dec 14th.
    Value of Cycle_dt in target table should be end date of past week like 07-Dec-2008, 14-Dec-2008.
    Please help me with the logics for both Monthly and Weekly reports.
    Thanks

    Hi,
    For the monthly report, instead of
    Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’say:
    Where   Record_dt >= TRUNC (ADD_MONTHS (SYSDATE, -1), 'MM')
    and     record_dt <  TRUNC (SYSDATE, 'MM')SYSDATE is the current DATE.
    TRUNC (SYSDATE, 'MM') is the beginning of the current month. (Notice the condition above is less than this date, not equal to it.)
    ADD_MONTHS (STSDATE, -1) is a date exactly one month ago, therefore it is in the previous month.
    For the weekly report, instead of:
    Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’say
    Where   Record_dt >= TRUNC (SYSDATE - 7, 'IW')
    and     record_dt <  TRUNC (SYSDATE, 'IW')TRUNC (dt, 'IW') is the beginning of the ISO week (Monday-Sunday) that contains dt. Again, notice the end condition is strictly less than the beginning of the current week.

  • Help needed in PL/SQL for updating the column for multiple records

    Hi,
    I am new to PL/SQL and need some help. What is the most effiecient way to update some field in a table as I may need to update thousands of records. I have a coulmn groupid can have multiple records tied to it. All the records attached to some groupid have a priority field also.
    How can I update the prorityfield value for all the groupids in a profiecient way. Here is a sample data
    GroupId     Priority
    1            1
    1            2
    1            3
    1            4
    1            5
    2            1
    2            2
    2            3
    3            1Here I have three groups 1, 2, 3. Now if any group contains only one record the priority remains same e.g. groupid=3 on top. If any group contains more than one record e.g. groupid=1 & 2 I want to re-arrange the priority fields e.g. If I want to update groupid=1 now if I change the priority of 2 to 5 (make it the last) I want to rearrange the remaing records priority i.e. if 2 becomes 5 as I have 5 rows for groupid=1 then 5 becomes 4, 4 becomes 3, 3 becomes 2 and 1 remains the same.
    Same wya if I want to make the priority 1 to 3 for groupid=2 then need 2 to become 1 and 3 to become 2 etc....
    Any help is appreciated.
    Thanks

    Hi,
    You don't need PL/SQL to do this (though you can put the following in PL/SQL if you want to):
    UPDATE     table_x
    SET     priority = CASE
                   WHEN  groupid     = 1
                   AND   priority = 2
                        THEN  5
                   WHEN  groupod     = 1
                   AND   priority     BETWEEN 3 AND 5
                        THEN  priority - 1
                   WHEN  groupid = 2
                   THEN
                        CASE
                             WHEN  prioity = 1
                             THEN  3
                             ELSE  priority - 1
                        END
                 END
    WHERE     groupId          IN (1, 2)
    AND     (     priority     BETWEEN 2 AND 5
         OR     groupid          = 2
         );There are lots of different techniques that can reduce your coidng: for example, the nested CASE statement used for groupid=2 above.
    You could do several smaller UPDATEs (for example, one just for groupid=1). Execution will be slower, but coding and testing will be faster.
    You could make the "magic numbers" 2 (for groupid=1) and 1 (for groupid=2) variables, even outside of PL/SQL.
    If you need more help, post the information that Satyaki requested.

  • Sql to count the no. of entries

    Hi all,
    I know that we can count the no. of entries with
    SY-DBCNT,
    but besides this, can I directly use sql statement, e.g. select count...
    to count the no. of entries?
    Thanks.

    Hi Macy,
        We can use like this.
        SELECT count(*) into l_var1
               from <db table>
               where <cond>.
        I think the above statement solves your problem.
    Regards,
    Ganesh N

  • SQL to count the number of days between two dates

    Does any one have or know how to count the number of days/weeks between 2 dates.
    I have thought about using MONTHS_BETWEEN, but do not know how to make it accurate down to one day?
    Any suggestions would be appreciated.

    here are the different queries I came up with to do this, you may want to check it for perticular cases involving Sun and Sat as start and end dates.
    select to_number(to_char(to_date('21-JUL-00','dd-mon-yy'), 'ww'))
    - to_number(to_char(to_date('10-JUL-00','dd-mon-yy'), 'ww')) from dual;
    select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-1, 'Sunday')
    - Next_Day(to_date('10-JUL-00','dd-mon-yy')-1, 'Sunday'))/7 from dual;
    select (Next_Day(to_date('21-JUL-00','dd-mon-yy')-6, 'Sunday')
    - Next_Day(to_date('10-JUL-00','dd-mon-yy')-6, 'Sunday'))/7 from dual;
    null

  • SQL for combine the column

    Hi there are two records, as follows
    a L1 M1
    a L1 M2
    the result expected
    a L1 M1,M2
    Could you help to give an example SQL for the result. Thanks for your help!
    Edited by: user12984790 on Jul 2, 2012 12:55 AM

    user12984790 wrote:
    11gThat is a product name. Not a product version. The version is a 4 digit number, e.g. 11.1.0.0 or 11.2.0.2. And there are differences in behaviour between versions.
    As for your problem - it is a FAQ (frequently asked question). Please read the very 1st posting to this forum - the forum FAQ. Pivots are covered in detail.

Maybe you are looking for

  • Unable to create the portable home directory for this user

    This is driving me nuts! I have a network user who I can login to on any machine on the network. I want a PHD to be created on a laptop and eveytime I answer 'yes' to 'create PHD for this user' I get the "unable to create the PHD for this user" messa

  • 'can we write the code in table maintanance generator?'

    HI Please let me know the answer for this,. thanks,

  • Adobe 9 mac download

    I have a serial number but can't find my disc for Adobe 9 acrobat, need to reinstall for MAC and it's not on the downloads available and not included with the CS5 that I downloaded and reinstalled, how can I get this?  Please help!!!

  • Maintain JCO destination button is disabled

    I am getting the following error when trying to log in to MSS: "com.sap.tc.webdynpro.services.exceptions.WDRuntimeE xception: Failed to resolve JCO destination name 'SAP_R3_SelfServiceGenerics_MetaData' in the SLD. No such JCO destination is defined

  • Export pdf per two pages

    Hey all, I need to export to pdf in 2-page-increments I found a somewhat similar script here in the forum but can't get it to work. Must be an error somewhere Would someone please check and correct this for InD CC2014? Thanks so much. // Output PDF p