Table hierarchy in a schema

Hi,
How to find the tables hierarchy in a schema?
the output show independent tables first then
primary key tables then foreign key tables.
I am not asking for single table.we need overall the tables in a schema in hierarchy manner.

check this link....
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:661009003696
and your query might me something like....
select rpad( '*', (level-1)*2, '*' ) || table_name table_name
   from (select a.table_name,
        a.constraint_name pkey_constraint,
            b.constraint_name fkey_constraint,
             b.r_constraint_name
    from user_constraints a, user_constraints b
  where a.table_name = b.table_name
   and a.constraint_type = 'P'
    and b.constraint_type = 'R'
    union all
    select table_name, constraint_name, null, null from user_constraints where
constraint_type= 'P'
) start with fkey_constraint is null
  --and table_name = '<tablename>' this is used when you want to know the hierarchy starting with a particular table.
  connect by nocycle prior pkey_constraint = r_constraint_name Ravi Kumar

Similar Messages

  • How to find full tables hierarchy in schema

    Hi,
    How to find the table hierarchy list from oracle schema by using Reference Key constraint?
    In my schema I am having many tables, approximate 4000 and from there I needs to get a single list which should be based in the Foriegn key based (Parent tables should be first then child tables)
    Regards
    Anee

    You can start with this
    select A.table_name children,
             B.TAble_name Father
    from DBA_CONSTRAINTS A,
            DBA_CONSTRAINTS B
    WHERE A.CONSTRAINT_TYPE = 'R'
         And B.Constraint_name = a.r_Constraint_name

  • How can i find out the table hierarchy

    Hi experts,
    I have one doubt. how can i find out the table hierarchy in the particular schema.
    Let me explain my requirement in detail.. In my Database i have nearly 250 table each table have it's own temporary table(for authorization purpose we are maintaining the temporary tables) for each day i have to clear the temporary table data.
    All temporary table connected with each other. i mean all the table having foreign key relationship.. while i attempt the delete the data from the temporary table it showed ORA-02292: integrity constraint  violated - child record found.
    So can any one please tell how can i delete the child table record first and then parent record table record.
    Thanks in advance
    Arun

    CREATE OR REPLACE FUNCTION get_child_tables (
    ptable VARCHAR2,
    powner VARCHAR2 DEFAULT 'SCOTT',
    plevel NUMBER DEFAULT 10
    RETURN stringarray
    -- -- create this ON SQL*PLUS "CREATE OR REPLACE TYPE STRINGARRAY AS TABLE OF VARCHAR2(50);"
    -- AUTHID CURRENT_USER
    PIPELINED
    AUTHOR DATE VERSION COMMENTS
    ======================================================================================
    [email protected] 26-OCT-2009 1.0 Developed to ease developers effort to find Nth level of Referential integrity
    ======================================================================================
    -- PURPOSE -> To find PARENT=> CHILD relational TABLE(S) in Oracle upto a depth max N Level.
    --SYNTAX TO USE
    SELECT * FROM TABLE( get_child_tables('DEPT','SCOTT',3)); Store this query in a file for your use
    SELECT * FROM TABLE( get_child_tables('EMPLOYEE')); Store this query in a file for your use
    -- RESULTS looks as below
    --1 => DEPT
    --2 => EMP
    --2 => EMP2
    --3 => EMP_CHILD
    --3 => EMP2_CHILD
    -- and so on
    --This can be leveraged to use in any oracle database REGION 10g having and above.
    --This FUNCTION gives formatted result of the Oracle 10g Hierarchical query result coded in the cursor
    --to find MASTER => CHILD relational TABLE(S) upto a depth max 10 Level.
    --The result of the PIPELINED function can be retrieved using Oracle new operator
    --TABLE(array name) in SQL query.
    --Due to the AUTHID CURRENT_USER compiler directive any user can use based on his/her access privileges on the database.
    --GRANT EXECUTE ON SCOTT.get_child_tables TO PUBLIC;
    --CREATE OR REPLACE PUBLIC SYNONYM get_child_tables FOR SCOTT.get_child_tables;
    IS
    atname stringarray := stringarray ();
    -- create this ON SQL*PLUS CREATE OR REPLACE TYPE STRINGARRAY AS TABLE OF VARCHAR2(50);
    vlevel NUMBER;
    vtname VARCHAR2 (50);
    nindex NUMBER := 0;
    bprocessed BOOLEAN := FALSE;
    CURSOR c1 (powner_in IN VARCHAR2, ptable_in VARCHAR2, plevel_in NUMBER)
    IS
    SELECT LEVEL, LPAD (' ', (LEVEL - 1) * 2, ' ') || pt AS "TNAME"
    FROM (SELECT a.owner w1, a.table_name pt, a.constraint_name c1,
    a.r_constraint_name r1, b.owner w2, b.table_name ct,
    b.constraint_name c2, b.r_constraint_name r2
    FROM all_constraints a, all_constraints b
    WHERE a.constraint_name = b.r_constraint_name(+)
    AND a.owner = b.owner(+)
    AND a.owner =
    UPPER (powner)
    -- Change Owner here while testing
    --AND A.r_constraint_name IS NULL
    AND a.constraint_type IN ('P', 'R')) v1
    START WITH pt =
    UPPER
    (ptable)
    -- Change your master table here while testing the QUERY
    CONNECT BY PRIOR ct = pt AND LEVEL <= plevel;
    -- Change lavel here while testing
    BEGIN
    atname.EXTEND;
    atname (1) := 'NOTHING';
    OPEN c1 (powner, ptable, plevel);
    LOOP
    bprocessed := FALSE;
    FETCH c1
    INTO vlevel, vtname;
    IF nindex > 1 AND atname (atname.LAST - 1) = vtname
    THEN
    --DBMS_OUTPUT.PUT_LINE('2 ==== vtname  ' ||vtname || '   '|| atname.count|| '   '||atname.last ||  '   '||atname( atname.last-1));
    bprocessed := TRUE;
    END IF;
    IF NOT bprocessed
    THEN
    nindex := nindex + 1;
    atname.EXTEND;
    atname (nindex) := vtname;
    PIPE ROW (vlevel || ' => ' || vtname);
    DBMS_OUTPUT.put_line ( ' **** nindex - atname( nindex) '
    || nindex
    || ' - '
    || atname (nindex)
    DLOG('ADDING ',vTname); A LOGGING ATONOMUS PROCEDURE FOR DEBUG PURPOSE
    END IF;
    EXIT WHEN c1%NOTFOUND;
    END LOOP;
    CLOSE c1;
    FOR i IN 1 .. atname.COUNT
    LOOP
    DBMS_OUTPUT.PUT_LINE('atname (i) ' ||atname (i));
    END LOOP;
    RETURN;
    EXCEPTION
    WHEN no_data_needed
    THEN -- THIS EXCEPTION HAS TO BE THERE TO GET THE FUCTION WORKABLE
    DBMS_OUTPUT.put_line (SQLERRM);
    RETURN;
    --SELECT * FROM TABLE( get_child_tables('TB_XOP_LETR_TEMPLATE','OPS$CMS',5));
    END get_child_tables;
    Edited by: user3066657 on Jul 21, 2011 8:42 AM
    Edited by: user3066657 on Jul 21, 2011 11:26 AM

  • Limitation on the number of tables in a Database Schema!

    Hi All,
    Is there a limitation on the number of tables present in a schema that can be fetched in Designer while creating a universe.
    Customer is using Oracle schema which contains 22000 tables and while trying to insert tables in Designer XIR2 (or trying to get the table browser) Designer hangs.
    In BO 6.5 there are no issues while retrieving the tables from the schema in Designer.
    Is there a way to retrieve only a certain amount of tables in Designer XIR2?
    Thanks for your help!

    Hi Ganesh,
    Following are the Answers regaring your queries:
    Query : 1
    There is no limitation on the number of components (objects, classes, tables, joins, hierarchies, lov's, etc) in a universe. But of course as the number of components increases, you could run into problems  related to performance.
    This depends on available RAM and the processing speed.
    Query 2:
    There is NO such option to select the number of table to be automatically inserted in to the universe because Suppose if you have 22000 tables in DB and you want only 1000 table ,you entered 1000 tables as the value to insert tables in Universe then How Designer will come to know which tables you want to take in Schema to build the Universe?
    It all depends on the DBA and Universe Designer which tables are important for organizations reporting needs.
    When you  create connection to the DB then Connection will fetch all table from the database and we canu2019t limit  DB data retrieval.
    I hope this Helps...
    Thanks...
    Pratik

  • How do i find out the tables effected in a schema after a particular time stamp

    how do i find out the tables effected in a schema after a particular time stamp?
    pls email in [email protected]

    If you are doing a reload every time then you can issue following commands to clear data from cube.
    lmt name to all
    allstat
    clear all from <cubename>prttopvar
    You can wrap above commands in pl sql procedure using dbms_aw.execute package and execute it before cube load starts. Instead of clearing it from whole cube you can clear only from one partition also. Just take a look at clear command in olap DML 10.2 reference.
    Thanks,
    Brijesh
    Edited by: Brijesh Gaur on Aug 10, 2010 6:47 AM

  • How can I create a table in other's schema?

    I have two users say 'user1' and 'sanju' along with other users in the database.Both the users are granted a connect role. I have connected as a 'sanju' user. Now I want to create a table in schema 'user1'.
    Please note that user 'sanju' should not be allowed to create table in any other user's schema.
    I have set the current schema of 'sanju' as 'user1'.
    ALTER SESSION SET CURRENT_SCHEMA=USER1
    I know that 'grant create ANY table to sanju' will allow 'sanju' to create table in all the schema. I dont want that. Is there any way to create a table in any other's schema?
    Please answer ASAP

    This is not directly possible, but you can use following workaround:
    connect user1/passwd
    create or replace procedure testCreateTable as
    begin
    execute immediate 'create table user1.testTable(c char)';
    end test;
    grant execute on testCreateTable to sanju;
    connect sanju/passwd
    execute testCreateTable
    Of course, you can make this procedure more generic by specifying the necessary parameter.
    Please not that this procedure only works, if user1 was granted the create table privilege directly, and not through a role (e.g. dba), because roles are disabled when executing

  • Tables in a different schema not visible from function

    I'm getting a really weird error in a function that I wrote. I have user "A" who has access to schemas for users "B" and "C". I need to update a table in schema "B" with data from schema "C". So, I created a function that selects information from a table in schema "B", uses that information to find the data of interest in schema "C" and then I update the table in schema "B" with the information I just looked up in schema "C". Clear so far?
    Anyway, when I try to create the function (I"m using SQLPLUS for all of this) I get an error message that the tables I am referencing in schema's "B" and "C" do not exist. However, if I modify the function so that I select a column that doesn't exists from a table in schema "B", then I get an error pointing this out to me. So, it seems weird that I have enough visibility into schemas "B" and "C" to know if I am accessing data by the correct column names, but when the column names are correct, I get an error message saying "table or view does not exist". I am in my development environment, and user "A" is granted the "DBA" role.
    So, here is my function. Note that I have qualified the table names with the schema owner (i.e. B.KPF_FOLDER_ITEMS) Any tips would be greatly appreciated. Database is 9i
    CREATE OR REPLACE FUNCTION migrate RETURN number
    IS
         v_parent_item_id           number(6);
         v_item_id               number(6);
         v_line_Item_id          number(6);
         -- variables for holding data returned from the actual product tables
         v_parent_item_number     varchar2(100);
         v_color_code          varchar2(100);     
    CURSOR folderProducts IS
         SELECT ITEM_ID as PRODUCT_PARENT_ITEM_ID, COLOR_ITEM_ID as ITEM_ITEM_ID, LINE_ITEM_ID as LINE_ITEM_ID
         FROM B.KPF_FOLDER_ITEMS
         WHERE table_prefix = 'STRL';
    BEGIN
         OPEN folderProducts;
         LOOP
              FETCH folderProducts INTO v_parent_item_id, v_item_id, v_line_item_id;
              EXIT WHEN folderProducts%NOTFOUND;
              -- get the product number
              SELECT BLAH.PARENT_ITEM_NUMBERX INTO v_parent_item_number
              FROM C.STRL_PRODUCTS BLAH
              WHERE BLAH.PARENT_ITEM_ID = v_parent_item_id;
              -- now get the color code
              SELECT ITEM.COLOR_FINISH_CODE INTO v_color_code
              FROM C.STRL_ITEMS ITEM
              WHERE ITEM.ITEM_ID = v_item_id;
              -- now, update the record in the kpf_folder_items table
              UPDATE B.KPF_FOLDER_ITEMS
              SET PRODUCT_NUMBER = v_parent_item_number,
                   COLOR_CODE = v_color_code
              WHERE LINE_ITEM_ID = v_line_item_id;
         END LOOP;
         CLOSE folderProducts;
    END;
    Edited by: user10219585 on Sep 3, 2008 11:30 AM correctly identified the schema for one of the tables.
    Edited by: user10219585 on Sep 3, 2008 11:31 AM

    Stored objects with DEFINER rights (default for stored objects) ignore role based privileges. Make sure SP owner is directly (not via role) granted privileges on objects in other schema.
    SY.

  • Moving Subpartitions to a duplicate table in a different schema.

    +NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
    Hello Ladies and Gentlemen.
    We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
    At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
    In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
    Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
    I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
    Any helpful replies welcome.
    Cheers.
    James

    You CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
    See :
    SQL> drop table part_subpart purge;
    Table dropped.
    SQL> drop table NEW_part_subpart purge;
    Table dropped.
    SQL> drop table STG_part_subpart purge;
    Table dropped.
    SQL>
    SQL> create table part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
      5  ,
      6  partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create index part_subpart_ndx on part_subpart(col_1) local;
    Index created.
    SQL>
    SQL>
    SQL> insert into part_subpart values (1,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'C');
    1 row created.
    SQL> insert into part_subpart values (11,'A');
    1 row created.
    SQL> insert into part_subpart values (11,'C');
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> create table NEW_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
      5  ,
      6  partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create table STG_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  /
    Table created.
    SQL>
    SQL> -- ensure that the Staging table is empty
    SQL> truncate table STG_part_subpart;
    Table truncated.
    SQL> -- exchanging a subpart out of part_subpart
    SQL> alter table part_subpart exchange subpartition
      2  p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL> -- exchanging the subpart into NEW_part_subpart
    SQL> alter table NEW_part_subpart exchange subpartition
      2  n_p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL>
    SQL>
    SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
         COL_1 COL_2
            11 A
    SQL>
    SQL> select * from part_subpart subpartition (p_2_s_1);
    no rows selected
    SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
    NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
    Added clarification for cross-schema exchange.

  • SSIS 2012 is intermittently failing with below "Invalid date format" while importing data from a source table into a Destination table with same exact schema.

    We migrated Packages from SSIS 2008 to 2012. The Package is working fine in all the environments except in one of our environment.
    SSIS 2012 is intermittently failing with below error while importing data from a source table into a Destination table with same exact schema.
    Error: 2014-01-28 15:52:05.19
       Code: 0x80004005
       Source: xxxxxxxx SSIS.Pipeline
       Description: Unspecified error
    End Error
    Error: 2014-01-28 15:52:05.19
       Code: 0xC0202009
       Source: Process xxxxxx Load TableName [48]
       Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Invalid date format".
    End Error
    Error: 2014-01-28 15:52:05.19
       Code: 0xC020901C
       Source: Process xxxxxxxx Load TableName [48]
       Description: There was an error with Load TableName.Inputs[OLE DB Destination Input].Columns[Updated] on Load TableName.Inputs[OLE DB Destination Input]. The column status returned was: "Conversion failed because the data value overflowed
    the specified type.".
    End Error
    But when we reorder the column in "Updated" in Destination table, the package is importing data successfully.
    This looks like bug to me, Any suggestion?

    Hi Mohideen,
    Based on my research, the issue might be related to one of the following factors:
    Memory pressure. Check there is a memory challenge when the issue occurs. In addition, if the package runs in 32-bit runtime on the specific server, use the 64-bit runtime instead.
    A known issue with SQL Native Client. As a workaround, use .NET data provider instead of SNAC.
    Hope this helps.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • How to export and import dependent tables from 2 different schema

    I have a setup where schema1 has table 1 and schema 2 has table2. And table 1 from schema1 depends upon table 2 from schema 2.
    I would like to export and import these tables only and not any other tables from these 2 schemas with all information like grants,constraints.
    Also will there be same method for Oracle 10g R1,R2 and Oracle 11G.
    http://download.oracle.com/docs/cd/B12037_01/server.101/b10825/dp_export.htm#i1007514
    Looking at this For table mode it says
    Also, as in schema exports, cross-schema references are not exported
    Not sure what this means.
    As I am interested in only 2 tables I think I need to use table mode. But if I try to run export with both tables names, it says table mode support only one schema at a time. Not sure then How would the constraints would get exported in that case.
    -Rohit

    worked for my 1st time I tried
    exp file=table2.dmp tables="dbadmin.temp1,scott.emp"
    Export: Release 10.2.0.1.0 - Production on Mon Mar 1 16:32:07 2010
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Username: / as sysdba
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses WE8ISO8859P1 character set (possible charset conversion)
    About to export specified tables via Conventional Path ...
    Current user changed to DBADMIN
    . . exporting table                          TEMP1         10 rows exported
    EXP-00091: Exporting questionable statistics.
    Current user changed to SCOTT
    . . exporting table                            EMP         14 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    Export terminated successfully with warnings.

  • How can i import tables from a different schema into the existing relational model... to add these tables in the existing model? plss help

    how can i import tables from a different schema into the existing relational model... to add these tables in the existing relational/logical model? plss help
    note; I already have the relational/logical model ready from one schema... and I need to add few more tables to this relational/logical model
    can I import the same way as I did previously??
    but even if I do the same how can I add it in the model?? as the logical model has already been engineered..
    please help ...
    thanks

    Hi,
    Before you start, you should probably take a backup copy of your design (the .dmd file and associated folder), in case the update does not work out as you had hoped.
    You need to use Import > Data Dictionary again, to start the Data Dictionary Import Wizard.
    In step 1 use a suitable database connection that can access the relevant table definitions.
    In step 2 select the schema (or schemas) to import.  The "Import to" field in the lower left part of the main panel allows you to select which existing Relational Model to import into (or to specify that a new Relational Model is to be created).
    In step 3 select the tables to import.  (Note that if there are an Foreign Key constraints between the new tables and any tables you had previously imported, you should also include the previous tables, otherwise the Foreign Key constraints will not be imported.)
    After the import itself has completed, the "Compare Models" dialog is displayed.  This shows the differences between the model being imported and the previous state of the model, and allows you to select which changes are to be applied.
    Just selecting the Merge button should apply all the additions and changes in the new import.
    Having updated your Relational Model, you can then update your Logical Model.  To do this you repeat the "Engineer to Logical Model".  This displays the "Engineer to Logical Model" dialog, which shows the changes which will be applied to the Logical Model, and allows you to select which changes are to be applied.
    Just selecting the Engineer button should apply all the additions and changes.
    I hope this helps you achieve what you want.
    David

  • How do you join two tables from different Oracle schemas using a subquery

    I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
    The query is as follows:
    sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
    + "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
    + "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
    + "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
    The format of the query is copied from a SQL programming manual.
    I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
    Edited by: user11338343 on Oct 19, 2009 6:55 AM

    I believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
    If you want to do a straight join without a subquery you could do the following
    SELECT  DD_12809.PDTABLE_12_1.LINE_ID
    ,       FAB.MAT_DESCRIPTION
    FROM    DD_12809.PDTABLE_12_1
    JOIN    RA_12809.PDTABLE_201    AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS  HTH!

  • How will get the source code of all the tables in a given schema using SQL?

    Hi All,
    How can we get the source code of all the tables in a given schema using SQL?
    Thanks in Adv.
    Junu

    Try something like...
    set heading off
    set pagesize 0
    col meta_data for a96 word_wrapped
    set long 100000
    SELECT DBMS_METADATA.GET_DDL(object_type, object_name, owner) ||';' AS meta_data
    FROM dba_objects
    WHERE owner = '<SCHEMA NAME>'
      AND object_type not in (<list of stuff you do not want>);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to gather table stats for tables in a different schema

    Hi All,
    I have a table present in one schema and I want to gather stats for the table in a different schema.
    I gave GRANT ALL ON SCHEMA1.T1 TO SCHEMA2;
    And when I tried to execute the command to gather stats using
    DBMS_STATS.GATHER_TABLE_STATS (OWNNAME=>'SCHMEA1',TABNAME=>'T1');
    The function is failing.
    Is there any way we can gather table stats for tables in one schema in an another schema.
    Thanks,
    MK.

    You need to grant analyze any to schema2.
    SY.

  • Compare table data between two schemas?

    Hi,
    I am looking for a script to compare the table data between the schemas (two different databases)? I know how to compare table by table but looking for a generic script where I can compare all the tables data from one schema to another schema?
    Thanks a lot...

    here the idea, adapt it with your needs :)
    Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    Connected as SYS
    SQL> create user user1 identified by user1;
    User created
    SQL> grant create  session to user1;
    Grant succeeded
    SQL> grant create table to user1;
    Grant succeeded
    SQL> alter user user1 quota 10m on DATA;
    User altered
    SQL> create user user2 identified by user2;
    User created
    SQL> alter user user2 quota 10m on DATA;
    User altered
    SQL> grant create table to user2;
    Grant succeeded
    SQL> grant create  session to user2;
    Grant succeeded
    SQL> create table user1.test(a Number) tablespace DATA;
    Table created
    SQL> create table user2.test(a Number) tablespace DATA;
    Table created
    SQL> insert into user1.test values (1);
    1 row inserted
    SQL> insert into user1.test values (2);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> insert into user2.test values (2);
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> create table sys.logs(Diff number) tablespace data;
    Table created
    SQL> select * from sys.logs;
          DIFF
    SQL>
    CREATE OR REPLACE PROCEDURE TEST_MY_DIFF IS
      CURSOR CUR_ IS
        SELECT D.TABLE_NAME T_NAME FROM DBA_TABLES D WHERE D.OWNER = 'USER1';
      W_DIFF NUMBER;
      TYPE CV_TYP IS REF CURSOR;
      CV CV_TYP;
    BEGIN
      EXECUTE IMMEDIATE 'TRUNCATE TABLE SYS.LOGS';
      FOR I IN CUR_ LOOP
        W_DIFF := 0;
        OPEN CV FOR 'select count(*)
    from
    ( select * from USER1.' || I.T_NAME || '
    minus
    select * from USER2.' || I.T_NAME || ' )
    union all
    ( select * from USER2.' || I.T_NAME || '
    minus
    select * from USER1.' || I.T_NAME || ')
        LOOP
          FETCH CV
            INTO W_DIFF;
          INSERT INTO SYS.LOGS VALUES (W_DIFF);
          COMMIT;
          EXIT WHEN CV%NOTFOUND;
        END LOOP;
      END LOOP;
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END;
    SQL> BEGIN
      2  test_my_diff;
      3  end;
      4  /
    PL/SQL procedure successfully completed
    SQL> select * from sys.logs;
          DIFF
             1
             1

Maybe you are looking for

  • Error Checking File System that doesn't exist anymore [Solved]

    I had been dual booting Arch and Ubuntu on my desktop and recently decided to ditch ubuntu and experiment with slackware. I also decided to take advantage of the reinstall to clean up my partition scheme. The old: sda1 ntfs windows sda2 fat32 shared

  • Using LINQ to extract list from XML [OpenXML]

    The following is the XML file that is generated from Word document through OpenXML: XML Link here I want to get the following list using LINQ:

  • NOT IN in OWB JOIN OPERATOR

    Select name from table_a where name not in (select related_name from table_b)           ---neither of the attributes are in a key Select name from table_a where name != any (select related_name from table_b)           -- this query makes Cartesian re

  • IDOC : SALESORDER_CREATEFROMDAT202

    Hi everyone, I am trying to execute the IDOC SALESORDER_CREATEFROMDAT202. I am getting some dificulties. I tried to fill the segments but I get an error. The header segment is E1SALESORDER_CREATEFROMDAT2. a) How do I fill it : it is not a structure l

  • Mac Pro / Cinema Display slow boot time

    Hi there, I have a late 2008 Mac Pro, running OSX 10.6.8 and it is connected to a 23" Apple Cinema Display. A couple of days ago I noticed that when I switched the Mac on, the display would not turn on. I forced it to shut down by holding the power b