How to check relation between two tables in same database

How to check relation between two tables in same database using Oracle SQL developer. Version 2.1.1.64

Hi,
Try this,
SELECT   cons.owner AS child_owner, cons.table_name AS child_table,
         cons.constraint_name constaint_name,
         cons.constraint_type constraint_type, col.owner parent_owner,
         col.table_name parent_table, col.column_name column_name
    FROM dba_cons_columns col, dba_constraints cons
   WHERE cons.r_owner = col.owner
     AND cons.r_constraint_name = col.constraint_name
     AND col.owner = 'MY_USER'
ORDER BY child_table;Thanks,
Shankar

Similar Messages

  • How to manipulate data over two tables in same database.

    hi, i am not a profficient java programmer, i was trying to copy filtered data from one table to another table.
    i was trying to use
    public static Connection getConnection() throws Exception {
         Driver d = (Driver)Class.forName
             ("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
         Connection c = DriverManager.getConnection
             ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=stuff.mdb");
         return c;
    and then
        theConn = myConnection.getConnection();
          ResultSet rs;
          Statement stmt;
          String sql;
          stmt = theConn.createStatement();
          sql =  "SELECT * FROM shisab, myhisab WHERE shisab.Who_Bought ='ron'";
               rs = stmt.executeQuery(sql);
               while (rs.next()) {
                System.out.println("date:"+rs.getString("shisab.Date"));                 
          rs.close();--------------------------------------
    it does not show anything! in the output! i tried many things but i thing it is not supporting my multiple table syntax , i.e.: table1,table2 in teh from clause.
    please help!
    i just need to filter stuff from the shisab table and write the filtered data into
    the myhisab table.

    Your problem isn't in the Java code, it's your SQL code...
    Your statement, as submitted, is an improperly formed multi-table select, where you never joined the second table. That won't work.
    You need to look into the INSERT INTO statement. The exact syntax of your statement will depend on whether or not both tables contain the exact same column names, etc. A generic example based on what you have might look like:
    INSERT INTO myhisab SELECT * FROM shisab WHERE Who_Bought = 'ron'HTH

  • How to check similarity between two Databases 9i & 10g after imp in 10g

    Dear all,
    Source
    =======
    OS server     ==>     HP-UX
    Oracle version     ==>     Oracle 9.2.0.8
    DB Name          ==>     MSST
    DB total users     ==>     320
    Full export in     ==>     /u02/export/Jan09.dmp
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    Destination
    ============
    OS server          ==>     HP-UX
    DB Name               ==>     CHDB
    Existg DB users          ==>     20
    Oracle version          ==>     Oracle 10.2.0.4
    copied 9i dump file in     ==>     /u03/export
    Tablespaces created same as Oracle 9i i.e;          
    Tablespaces     ==>     SC, SC_I, SA, SA_I, PP, PP_I, AC, AC_I, SD
    I had run full import on Destination server i.e; Oracle 10g & following is the command i used:
    imp system/pwd@conn_string file=/u03/export/Jan09.dmp log=/u03/export/Jan09_imp.log full=y ignore=y statistics=none
    *=== Imported successfully with few errors like ====*
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_PROMOTIONS_ORD" ADD CONSTRAINT "EMP_PROMOTIONS_ORD_UK" UN"
    "IQUE ("EMP_NO", "RANK_NO_FOLLOW") USING INDEX PCTFREE 10 INITRANS 2 MAXTRAN"
    "S 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP" "
    "LOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    ORA-02299: cannot validate (PP.EMP_PROMOTIONS_ORD_UK) - duplicate keys found
    . . importing table "EMP_PROMOTION_DETAILS" 13333 rows imported
    . . importing table "EMP_PROMOTION_MAST" 725 rows imported
    . . importing table "EMP_PUNISHMENT" 271 rows imported
    . . importing table "EMP_REPORT_BOOKS" 60528 rows imported
    . . importing table "EMP_SALARY_HISTORIES" 120871 rows imported
    . . importing table "EMP_SALARY_HISTORIES_TEMP" 77044 rows imported
    . . importing table "EMP_TRANSACTIONS" 96536 rows imported
    IMP-00017: following statement failed with ORACLE error 2299:
    "ALTER TABLE "EMP_TRANSACTIONS" ADD CONSTRAINT "TRANS_UK" UNIQUE ("EMP_NO","
    " "DIR_NO", "DIR_DATE", "TRN_CODE") USING INDEX PCTFREE 10 INITRANS 2 MAXTRA"
    "NS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "PP_"
    "I" NOLOGGING ENABLE "
    IMP-00003: ORACLE error 2299 encountered
    ORA-02299: cannot validate (PP.TRANS_UK) - duplicate keys found
    Now my question is
    ===================
    How to check everything is same/similar like Oracle 9i database ( source ), for example ( i used this technique ):
    Can anyone tell me how to check similarity between two Databases 9i & 10g after import in 10g.
    MSST_DB>SHOW USER
    MSST_DB>SA
    MSST_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    DATABASE LINK     2
    FUNCTION     23
    INDEX          1795
    LOB          6
    PACKAGE          8
    PACKAGE BODY     8
    PROCEDURE     30
    SEQUENCE     67
    SYNONYM          60
    TABLE          644
    TRIGGER          3
    VIEW          20
    CHDB_DB>SHOW USER
    CHDB_DB>SA
    CHDB_DB>select object_type, count(*) from user_objects group by objects;
    OBJECT_TYPE     COUNT(*)
    INDEX          1794
    PROCEDURE     30
    TABLE          644
    TRIGGER          3
    VIEW          20
    FUNCTION     23
    SYNONYM          60
    PACKAGE BODY     8
    SEQUENCE     67
    PACKAGE          8
    LOB          6
    Edited by: VIKHARAHMED on Jan 10, 2012 3:02 AM

    [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_export.htm#sthref67]Guide.

  • How to implement Master - Detail relation between two table views in OBI11g

    Hi Gurus,
    I was able to create master- detail between table and graph.
    But between two tables not.
    I put the listening column on the table prompt and specified channel for the Listen to Master-Detail Events in the table properties.
    But did not work.
    Where is the mistake?
    I"d appreciate any ideas, help!
    Thanks
    Laszlo

    Thanks for the link!
    My question is :
    Are the same thinga the page edge and table prompt for the tables?
    If not how to add a column to the page edge (not to the table prompt)?
    Thanks
    Laszlo

  • How to compare data between two tables?

    Hi,
    My team is trying to develop a SAP data migration tool (DMT) using ABAP.
    One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
    The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
    How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
    Any help would be greatly appreciated, thanks!

    Hi Kian,
    Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
    Thanks,
    Vinay

  • How to give relationship between two tables with comon column with between oprator

    Hi Folks,
    I am using Sql Server 2008R2. I am getting a problem to establish relationship between two tables. 
    I have two Tables, 1.Inventory Details Table another one is Inventory Header Table.
    Inventory Details Table having a column Card No and inventory Header Table having columns  From card No and To Card No.
    I want to give relationship between these two tables with Card no. Could you please provide me the Sql Query.
    Your help would be greatly appreciated .
    Regards
    hasthi.
    email:[email protected]

    Hi Raju,
     We have two way that we can relate to the table either join or quality condition use following syntax/Query  for relating two tables 
    select * from Inventory_Details ID inner join  Inventory_Header IH on ID.CardNo between IH.FrmCardno and IH.ToCardNo
    or 
    Select * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo=IH.CardNo OrSelect * from  Inventory_Details ID ,Inventory_Header IH where ID.CardNo between IH.FrmCardno and IH.ToCardNo
    Hope this will help you 
    Niraj Sevalkar

  • Subject: How to do join between two tables using something like SE16

    SE16, SE11 provide form based interface query information from a single table. Is there a way to do join between two tables without creating an infoset erc? I am looking for something similar to sql join but in SAP BI 7.0
    Thanks.

    Hi
    Pls look into below links. Hope this helps you.
    1. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45bf455611d189710000e8322d00/content.htm
    2. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45a5455611d189710000e8322d00/content.htm
    Regards
    Sirigiri

  • How can we navigate between two windows of same component in webdynpro ABAP

    Hi
    how can we navigate between two windows( not views ) of same component in webdynpro ABAP. its an urgent requirement
    Thanks in advance.
    Regards
    Laeeq

    Hi Laeeq,
    You cannot navigate between windows of one component. You can only call a dialog box showing the contents of a second window, or you can embed the contents of a window of a different component.
    Just add all the views you need to the one and only main window of the component.
    Ciao, Regina

  • How to check differences between two bpel jar files

    Hi,
    Can some one please suggest, how to check the differences between two versions of a BPEL process jar files.
    Thanks in advance!

    Hi,
    Try this,
    SELECT   cons.owner AS child_owner, cons.table_name AS child_table,
             cons.constraint_name constaint_name,
             cons.constraint_type constraint_type, col.owner parent_owner,
             col.table_name parent_table, col.column_name column_name
        FROM dba_cons_columns col, dba_constraints cons
       WHERE cons.r_owner = col.owner
         AND cons.r_constraint_name = col.constraint_name
         AND col.owner = 'MY_USER'
    ORDER BY child_table;Thanks,
    Shankar

  • Compare data between two tables of same schema

    Folks,
    I have one very intresting query which i would like to share with you all and looking forward for the solution asap.
    Scenario
    I have two table say TableA and TableB, both having same structre say as below
    TableA
    Col1 Var(10)
    Col2  INT
    TableB
    Col1 Var(10)
    Col2  INT
    I want to compare data between these two tables and store compared data into third table, let me expalin the whole scenario.
    TableA
    ColA          ColB
    INDIA          1
    PAKistan      2
    TableB
    ColA          ColB
    INDIA          1
    PAK             3
    I want result like
    Difference
    ColA          ColB
    True            0
    False           -1
    I want to store this difference in thrid table.
    i.e. when comparing text, i need TRUE when compare 100% else False, Caption is not considered.
         When comparing numeric value, simple sub is requried , TableA-TableB
    Note - I dont want to use any external tool to compare the table data, i required sql query to do the same.
    Thanks
    Amit Srivastava
    Amit
    Please mark as answer if helpful
    http://fascinatingsql.wordpress.com/

    Whereas the abbreviation of countries that exist in Table2 table are the first three letters of the name of the country*, here's a suggestion:
    -- code #1 v2
    INSERT into [Difference] (Col1, Col2, ACol1, BCol1)
    SELECT case when A.Col1 = B.Col1 then 'true' else 'false' end,
    (IsNull(A.Col2, 0) - IsNull(B.Col2, 0)), A.Col1, B.Col1
    from TableA as A full outer join
    TableB as B on (A.Col1 = B.Col1
    or Left(A.Col1, 3) = B.Col1);
    Is the COLLATE database case insensitive? If not, the code #1 above will have to be modified, using the upper () function or using COLLATE case insensitive in A.Col1 and B.Col1 columns.
    But if the abbreviation of the country follow the
    ISO 3166-1 alpha-3 standard, will require a fourth table containing the symbol and name of countries.
    -- code #2 v2
    ;with
    TableB_2 as (
    SELECT case when Len(Col1) = 3
    then (SELECT Country_name from [ISO 3166-1 a3] where Cod = Col1)
    else Col1 end as Col1, Col2
    from TableB
    INSERT into [Difference] (Col1, Col2, ACol1, BCol1)
    SELECT case when A.Col1 = B.Col1 then 'true' else 'false' end,
    (IsNull(A.Col2, 0) - IsNull(B.Col2, 0)), A.Col1, B.Col1
    from TableA as A full outer join
    TableB_2 as B on A.Col1 = B.Col1;
    Structure and data to test:
    use tempdb;
    CREATE TABLE TableA (Col1 varchar(10), Col2 int);
    CREATE TABLE TableB (Col1 varchar(10), Col2 int);
    CREATE TABLE [Difference] (Col1 varchar(10), Col2 int, ACol1 varchar(10), BCol1 varchar(10));
    INSERT into TableA values ('INDIA', 1), ('PAKistan', 2), ('China', 12);
    INSERT into TableB values ('INDIA', 1), ('PAK', 3), ('Bhutan', 3);
    go
    CREATE TABLE [ISO 3166-1 a3] (Cod char(3) primary key, [Country_name] varchar(30));
    INSERT into [ISO 3166-1 a3] values
    ('IND', 'India'), ('PAK', 'Pakistan'), ('CHN', 'China'), ('BGD', 'Bangladesh'),
    ('BTN', 'Bhutan'), ('MMR', 'Myanmar'), ('NPL', 'Nepal');
    go
    (*) If the short form of the country name using the first three letters of the country name,
    false positives can occur. For example,
    Mali and Malta or
    Angola and Anguilla.
    José Diz     Belo Horizonte, MG - Brasil

  • PO Stylesheet How to remove space between two tables

    Hi
    I am building a rtf template for PO output for communication report in r12,there is a terms and conditions part and total amount part which comes at bottom of every page of the report. I have created that as a template and i call it in the footer.
    The problem is there is always a gap between the lines table and the terms & conditions and total table,any idea's on how to resolve this issue will be very helpful.
    Please let me know if any other input is required from my side.
    Thanks in Advance

    Are you trying to have the table where the lines are always be the same size no matter how many lines are present?
    If so, you some choices:
    1) If your lines are always the same height, you might get some ideas on what to do from this article:
    http://oracle.anilpassi.com/xml-publisher-developing-reports-printed-on-pre-printed-stationary.html
    2) If your lines vary in height, then you should look into a PDF template. This will give you a pre-printed stationary look in which the drawing of boxes and lines is not affected by the data content.
    3) Other less attractive options are a) making the report in XSL-FO, and b) making a bitmapped RDF report
    There is currently no solution that I am aware of for a pre-printed stationary look using an RTF template in which the data lines are of variable height.

  • Relate between two tables in ALV REPORT(SAP-ABAP)

    Hi Friends,
         I want to retrieve name1 and city1 from <b>kna1</b> , and kunrg from <b>vbrk</b>.
         Could u pls tell me on what basis i should pick these value ?
    Thx and Regds,
    Bapi

    Hi
    tables: kna1
    select single KUNNR name1 ort01 from kna1 where kunnr = vbrk-kunrg.
    or
    select single KUNNR name1 ort01 from kna1 where kunnr = vbrk-kunag.
    write: / kna1-kunnr, kna1-name1, kna1-ort01.
    <b>
    link between tables is
    VBRK-KUNAG = KNA1-KUNNR (customer/Sold to party)
    Reward points for useful Answers</b>
    Regards
    Anji
    Message was edited by:
            Anji Reddy Vangala

  • How to transfer data between two tables

    Hi friends i have got a new problem actually i'm a fresher in this SAP so i have a doubt in SAP Smart Forms the problem is like this
    I have a data element common in both of the tables BSEG and KNA1 and the common data element is KUNNR so i want to transfer all the data in the table BSEG to KNA1 of the same data element(KUNNR) in which there is data regarding customer information so i want to transfer the single customer data into another table KNA1 and i want to display the data in the output plz any one can help me.

    hi.
    the below metjhod u can adopt.
    1)
    select data from 1st zable to internal table.
    2)insert data from internal table to 2nd ztable simple.
    data:begin of itab occurs 0.
    include structure ztable_structure1.
    data:end of itab.
    select * from ztable into table itab.
    modify ztable1 FROM TABLE itab.
    3 ) ike that u can catch date from other table.
    4) if any condition is there u can check it in the internal table.
    Rgds
    Anver
    if hlped pls mark points

  • How to copy data between two tables row by row

    Hi All,
    I have three tables TableA and TableB and TableC
    I wanted to write a stored procedure to copy data row by row from TableA to TableB and then update TableC by replacing any record that has the old id (before copying) to the new id after copying the data.
    here is the steps 
    iterate throw all the rows in tableA ( probably with a foreach)
    in each iteration we will do the following:
    Get current ID (identity) for each record in TableA ( will call it @oldID)
    Insert the row in TableB
    Get the new ID for the row from TableB will call it (@NewID)
    find rows in tableC that has the (@oldID)
    replace all ids in tableC with @oldID to @NewID
    Thanks in advance

    0
    TableA and TableB are identical they should have the same columns 
    TableC columns will be ( ID, TableA_ID , Notes)

  • How to create a view between two table under different database?

    thx

    Assuming the different database is Oracle, you'll probably need to create a 'dblink'. Researching that topic should get you where you need to go.

Maybe you are looking for

  • Issue in Extending VO

    Hi Iam trying to extend a VO when Iam editing the SQL Statement by just adding a column to it at the Attribute mapping level it is showing as transient and later it is not allowing to update the column in base table At some situation some Query Colum

  • Poriblems with Server Side Include

    I amtrying to convert to Spry Menus using SSI. into a template.  been beating my head against the wall on what can go in and what can't in an include fil but that turns out not be my big problem when in using Dredamweaver CS5   and  do a server side

  • Links inside a portlet

    Hi, I've got 4 links inside a portlet, i woulld like to target each link to the same portlet. Basically,i want this links to open inside a portlet. <netui:anchor action="Week">|Week</netui:anchor> <netui:anchor action="DayofWeek" >|Day of Week</netui

  • Ssh-add does not stay, er, added...

    I'm troubleshooting an installation of SSH-Keys. I've successfully installed this with another user. After considerable effort can not discover why the two accounts do not behave the same. One account asks for the passphrase on login, and the other d

  • Overflow JTextPane

    I've got a task that I can't quite wrap my head around. I have a few thoughts on how to proceed but no sense of which idea might be better. I was hoping more experienced Swing developers might have some suggestions about these or better ways to proce