Associted two table where referential integrity constraint is  present

SELECT A.COLUMN_NAME,A.CONSTRAINT_NAME,B.CONSTRAINT_TYPE,A.TABLE_NAME FROM USER_CONS_COLUMNS A,USER_CONSTRAINTS B
WHERE A.OWNER=B.OWNER
AND A.OWNER='TEST'
AND A.TABLE_NAME=B.TABLE_NAME
AND A.CONSTRAINT_NAME=B.CONSTRAINT_NAME
AND A.TABLE_NAME='CN_SMSC'
from this query we can get name of the column ,const name,type and associated sigle table name.
my question is
==============
how will i get associted two table where referential integrity constraint is present

SELECT A.COLUMN_NAME,A.CONSTRAINT_NAME,B.CONSTRAINT_TYPE,A.TABLE_NAME "Detail Table", b.R_CONSTRAINT_NAME , c.TABLE_NAME "Primary table"
FROM user_CONS_COLUMNS A,user_CONSTRAINTS B, user_constraints c
WHERE A.OWNER=B.OWNER
AND A.OWNER='TEST'
AND A.TABLE_NAME=B.TABLE_NAME
AND A.CONSTRAINT_NAME=B.CONSTRAINT_NAME
and b.CONSTRAINT_type ='R'
and c.CONSTRAINT_NAME = b.R_CONSTRAINT_NAME
AND A.TABLE_NAME='CN_SMSC'

Similar Messages

  • Self Referential integrity constraint?

    What is self-referential integrity constraint? Is it a foreign key where the same column acts as the parent key too.

    The good old EMP table in the SCOTT schema is one example. Managers are employees, so the MGR column refers back to the EMPNO primary key. If I wanted to create my own table...
      1  create table emp2 (
      2   empno number primary key,
      3   mgr   number references emp2( empno )
      4* )
    SCOTT @ hp92 Local> /
    Table created.Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Tables with referential integrity

    Hi All,
    I am generating scripts to insert data from one schema to another. something like this:
    Insert into schemaA.table1
    select *from schemaB.table1;There are many tables with referential integrity in the schema. how can generate the scripts in an order so that there
    won' t be any referential integrity issue....
    Thanks.
    AJR

    Hi,
    Thanks.
    I tried, but it gives me 6 sets of data.
    SELECT TABLE_NAME--, LTRIM(SYS_CONNECT_BY_PATH(TABLE_NAME, '=>'),'=>') TABLE_NAME_PATH,CONSTRAINT_NAME, R_CONSTRAINT_NAME, LEVEL
    FROM   USER_CONSTRAINTS,ALL_OBJECTS B
    --WHERE  LEVEL > 1
    WHERE
    USER_CONSTRAINTS.OWNER = B.OWNER AND
    USER_CONSTRAINTS.TABLE_NAME = B.OBJECT_NAME AND
    B.OBJECT_TYPE = 'TABLE'
    CONNECT BY R_CONSTRAINT_NAME = PRIOR CONSTRAINT_NAME
    ORDER BY TABLE_NAME;AJR

  • How to export-import referential integrity constraints ?

    Hi all
    Is there any way to export only the referential integrity constraints from one user to another user ?
    Suppose i am having SCOTT user which is having EMP , DEPT tables . And also I am having another user (say TEST) which also is having those EMP and DEPT table but without the referential integrity constraints . Now can i export
    referential integrity constraints from SCOTT and import into TEST so that EMP,DEPT tables(in TEST) will have those referential integrity constraints which are present in SCOTT user ?
    Thanks
    Debashis
    Bangalore

    Hi,
    See the BAM Enterprise Link Utilities User's Guide for additional Enterprise Link import/export capabilities not exposed via ICommand.
    Regards, Stephen

  • Sql join on two tables where column like another column

    hi all,
    been trying to get the results from a join between two tables where one column is like another one.
    table1 (nameA) examples: black2, green1
    table2 (nameB) example: black2.location.uk.com, green1.location.uk.com
    so for example I want to match all those in table1 with black2 to the column in table2 that begins with black2 and so on if you see what im trying to get at!
    my sql so far:
    select * from  schema.table1 a
    join schema.table2 b
    on a.nameA like concat('%', b.nameB, '%'); but it errors:
    ORA-00909: invalid number of arguments
    00909. 00000 - "invalid number of arguments"
    Any help or advice would be greatly appreciated, thankyou!

    Either of these should do it...
    select * from  schema.table1 a
    join schema.table2 b on a.nameA like '%'||b.nameB||'%';or
    select * from  schema.table1 a
    join schema.table2 b on instr(b.nameB,a.nameA) > 0

  • Query to display the tables with referential integrity

    Hello,
    I need to display the Tables which are having referential integrity..
    Like need to dispaly the parent and child tables
    Please give me some idea on this..
    Thanks,

    Here's a nice query you can use:
    with temp_constraints as (
    select table_name
    ,      constraint_name pkey_constraint
    ,      null fkey_constraint
    ,      null r_constraint_name
    from   user_constraints
    where  constraint_type = 'P'
    union all
    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'
    select rpad( '*', (level-1)*2, '*' ) || table_name relation
    from   temp_constraints
    start with fkey_constraint is null
    connect by pkey_constraint <> r_constraint_name
    and prior  pkey_constraint = r_constraint_name;From http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:661009003696#tom69115451356231

  • To join two tables where relationship is Many-to-Many

    Hi All,
    I have two tables and want to join them, but my query does not give me the required output. I am sending you my query and tables.
    Used query
    SELECT COUNT(*)
         FROM TEMP_A A, TEMP_B B
         WHERE A.CAT_1=B.CAT_1
         AND A.CAT_2 = B.CAT_2
         GROUP BY A.CAT_1 , A.CAT_2, B.CAT_1, B.CAT_2
    Given output
    4
    required output
    2
    Temp_a
    idx cat_1 cat_2 Name
    101 790 5047 ABC
    2 01 790 5047 DEF
    Temp_b
    idx cat_1 cat_2 cat_name
    1 790 5047 Primary
    2 790 5047 Junior
    Best Regards,

    HI,
    this query does not work if i have more data like if I am sending you new table TEMP_A and TEMP_B as that was a sample data.
    Temp_a
    IDX     CAT_1     CAT_2     NAME
    101     790     5047     ABC
    201     790     5047     DEF
    301     795     5048     
    401     795     5048     
    501     795     5048     
    601     795     5048     
    701     795     5048
    temp_B
    IDX     CAT_1     CAT_2     CAT_NAME
    1     790     5047     Primary
    2     790     5047     JUNIOR
    3     795     5048     HIGHER
    4     795     5048     SECONDARY
    5     795     5048     COLLEGE
    6     795     5048     SENIOR
    This time the output should be 7 records while your query gives four records and mine gives 24 records.

  • How to get the list of tables having referential integrity connection

    Hi,
    I need to know the tables list of having foreign key relationship
    means
    I've table t1 and t2 and they have foreign key relation and t2 and t3 also having the same like i've almost 20 tables in connection...
    So please help me the script to find like above....
    Please let me know if i'm not clear

    Thank you for support and i'll try...
    And that is:
    create table log_table1
        (       theKey  int primary key,
                theKey1  int ,
                effDate date );
    create table log_table2
        (       theKey  int primary key,
                theKey1  references log_table1(theKey) ,
                effDate date );
    create table log_table3
        (       theKey  int primary key,
                theKey1  references log_table2(theKey) ,
                effDate date );     and tried the following query:
    select table_name
    from user_constraints
    where constraint_type='R'
    and r_constraint_name in
      (select constraint_name
      from all_constraints
      where constraint_type in ('P','U')
      and table_name='LOG_TABLE1');but getting
    TABLE_NAME
    LOG_TABLE2but i need to get the output LOG_TABLE2 & LOG_TABLE3 also

  • Can i Know any standard Table where all the Subroutines are present?

    Hi Folks,
    Please let me know the Standard table name where i can find all the Forms ( Subroutines) .
    Thanks,
    Naresh

    Hi,
    There is no Std table in SAP to store all the performs used in the program.
    Generally we use SCAN statement to find all the PERFORMS used in a program.
    reward if useful
    regards,
    Anji

  • Issue with Referential Integrity check in Oracle VPD Policy

    Hi,
    Lets assume I have two tables - Customer and Order, with cust_id in Order table referring to primary key of Customer table.
    Example Data;
    Customer
    cust_id Name
    1 abc
    2 def
    3 ghi
    Order
    Order_id cust_id Order_type
    1 1 A
    2 2 A
    3 1 B
    Now I have policies defined on both the tables;
    - for "Select, Insert, Update" queries on Customer table.
    - for "Select" queries on Order Table.
    Policy 1 on Order Table;
    Irrespective of the user, predicate = 'Order_type = ''A'''
    Policy 2 on Customer Table;
    Irrespective of the user, predicate = '(select count(1) from order o where o.cust_id = customer.cust_id and o.order_type = ''B'') > 0'
    My intention is to show only those customers who have atleast one order of type 'B'. And this policy works fine in case a user tries to read data from customer table. (for example, record for cust_id = 2 will not be returned as it don't have any orders of type "B")
    However, when a user tries to insert record in Order Table, because of the existing referential integrity constraint, the Policy on Customer table is also getting triggered. And an exception is being raised "ORA-28113: policy predicate has error".
    Could someone please explain why this is happening ?

    I'm afraid, there is no such a mean.
    At least I do not know about it.

  • Automated Solution for Integrity Constraints?

    Here is the situation. I have a parent table with child rows in LIVE. A workspace is then created, and another child is added to one of the parent rows in live. Another workspace is then created, and the parent row for the first workspaces child is deleted. The user tries to merge the second workspace to LIVE, which fails with a ORA-20237 error (expected).
    How do I in an automated fashion, determine what row(s) in what workspace(s) are causing the error workspace merge? This is on 10gR2.
    Integrity constraint violations do not show up in the CONF views, so that doesn’t help. I need to be able to eliminate the conflicts in an automated fashion, providing notice to the owners of the workspaces that they need to go revise the parts that were forcefully removed. But to do that, I need to know how to locate the issues causing the problem so I can build a package to do this, hands off.
    Example script:
    SQL> create table test_parent (pk number not null, name varchar2(50),
      2   CONSTRAINT test_parent_ndx PRIMARY KEY (pk));
    Table created.
    SQL> create table test_child (pk number not null,  fk number, name varchar2(
      2    CONSTRAINT test_child_ndx PRIMARY KEY (pk),
      3    CONSTRAINT test_child_FK01
      4   FOREIGN KEY (fk)
      5   REFERENCES test_parent (pk)
      6   on delete cascade);
    Table created.
    SQL> exec dbms_wm.enableversioning('test_parent,test_child');
    PL/SQL procedure successfully completed.
    SQL> insert into test_parent values (1, 'First item');
    1 row created.
    SQL> insert into test_parent values (2, 'Second item');
    1 row created.
    SQL> insert into test_child values (101, 1, 'References first item');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test_parent;
            PK NAME
             1 First item
             2 Second item
    SQL> select * from test_child;
            PK         FK NAME
           101          1 References first item
    SQL> exec DBMS_WM.createworkspace('1', TRUE, 'None',  TRUE );
    PL/SQL procedure successfully completed.
    SQL> exec DBMS_WM.gotoworkspace('1');
    PL/SQL procedure successfully completed.
    SQL> insert into test_child values (102, 1, 'References first item');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from test_parent;
            PK NAME
             1 First item
             2 Second item
    SQL> select * from test_child;
            PK         FK NAME
           101          1 References first item
           102          1 References first item
    SQL> exec DBMS_WM.gotoworkspace('LIVE');
    PL/SQL procedure successfully completed.
    SQL> exec DBMS_WM.createworkspace('2', TRUE, 'None',  TRUE );
    PL/SQL procedure successfully completed.
    SQL> exec DBMS_WM.gotoworkspace('2');
    PL/SQL procedure successfully completed.
    SQL> select * from test_parent;
            PK NAME
             1 First item
             2 Second item
    SQL> select * from test_child;
            PK         FK NAME
           101          1 References first item
    SQL> delete from test_parent where pk = 1;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> select * from test_parent;
            PK NAME
             2 Second item
    SQL> select * from test_child;
    no rows selected
    SQL> exec DBMS_WM.gotoworkspace('LIVE');
    PL/SQL procedure successfully completed.
    SQL> exec DBMS_WM.mergeworkspace('2', FALSE, FALSE, FALSE  );
    BEGIN DBMS_WM.mergeworkspace('2', FALSE, FALSE, FALSE  ); END;
    ERROR at line 1:
    ORA-20237: integrity constraint (CVC.TEST_CHILD_FK01) violated in workspace
    LIVE or one of its descendants - child record found
    ORA-06512: at "WMSYS.LT", line 6009
    ORA-06512: at line 1Bryan

    Hi Amit,
    The merge operation does result in the deletion of the row from both LIVE and the child workspace. However, this would cause the child table in the other (non-merged) workspace to have data without a corresponding parent row. We can not allow this, and so raise a referential integrity constraint violation. It is also not a conflict, as conflicts are always for rows with the same primary key, not for business conflicts or constraint violations. In the example, the inserted row in the child workspace was for a primary key that was unique within all workspaces, and so no conflict violation would be raised.
    The reason it works for a non-CR workspace, is that the parent table row is still visible from the other workspace as it was not automatically deleted.
    You can use the DIFF view(with SetDiffVersions) or the MW view(with SetMultiWorkspaces) to determine which rows were deleted from the parent table that you are merging. This information can then be used to find the other workspace/savepoint that is causing the violation and fix it. This could be done by removing the child row or inserting/updating the parent row prior to the other workspace being merged.
    Ben

  • Distributed referential integrity

    Hi, I have a question. If I am on the wrong forum please direct me as I could not find a specific forum for distrituted databases and these may be a application development question.
    I am implementing a simple distributed database application. At this point I am only concerned with creating two tables each on a different server. For simplicty I will name them table1 and table2. This would be the schema if the tables were not distributed and were located on the same server.
    CREATE TABLE table1 (
    table1_id NUMBER CONSTRAINT table1_pk PRIMARY KEY
    CREATE TABLE table2 (
    table2_id NUMBER,
    table1_id NUMBER,
    CONSTRAINTtable2_pk PRIMARY KEY (table2_id, table1_id),
    CONSTRAINT table2_fk FOREIGN KEY (table1_id) REFERENCES table1(table1_id)
    I have referred to the documentation in both Oracle® Database Administrator's Guide 10g Release 2 (10.2) and Oracle Database Application Developer's Guide. I know that I cannot use declarative referential integrity but how can I distribute the tables so that I can be sure that when I insert a row into table2, I can check to see if there is a matching row in table1 for table1_id?

    Realistically, I expect that you need to reconsider your architecture.
    It does not make sense to check for a matching row in table1 in a remote database while inserting data into table2 in a local database. The best case scenario would be that every insert into table2 would incur the overhead of a network round-trip plus the cost of querying the table in the remote database. If the network went down or if either of the two databases went down, the application would fail, which generally defeats the purpose of a distributed application. Plus, there would be all sorts of concurrency issues (i.e. I delete a row, but before I commit you query the row, see that it exists, and insert a child row. I commit, leaving your row orphaned).
    Assuming you really need a distributed architecture, you would want to replicate table1 to both the local and remote nodes. You would then declare referential integrity constraints between your local copy of table1 and table2 (as well as between table1 and table2 on the remote database, assuming you want table2 data available there as well). Your replication process (preferrably using Streams but potentially using multi-master materialized views instead) would then have to be coded to deal with errors because of the asynchronous nature of replication (i.e. to notice that database1 deleted a parent row that you just inserted a child row for and resolve the conflict appropriately).
    Justin

  • Integrity constraint child record found

    TopLink Version: Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 070323)
    I may be going crazy here, but I keep getting an integrity constraint when I try to delete an object that has 1:M relationship (Resource 1:M Attribute):
    Internal Exception: java.sql.SQLException: ORA-02292: integrity constraint (WEBCENTER.WP_RELATIONSHIP_RES_FK) violated - child record found
    The child object attribute is set to "Private Owned", and there is an FK from the child table to the parent table in the database (this is where the integrity constraint violation is coming from).
    I query for the Resource, register it in the unit of work, call UOW.deleteObject(resource), and then call UOW.commitAndResume(). TopLink is making a sql call to delete the Resource, but it does not first delete the privately owned Attributes which results in the FK violation.
    It should delete the child records first, right?
    In addtion to having the attribute set to "Private Owned", I also have set:
    Batch Reading
    Use Indirection
    Transparent
    Not sure if that makes a difference.

    Use a trigger. Example:
    CREATE OR REPLACE TRIGGER update_parent_chilren
    BEFORE UPDATE OF pkey_column ON parent_table
    FOR EACH ROW
    BEGIN
    UPDATE child_table
    SET fkey_column = :NEW.pkey_column
    WHERE fkey_column = :OLD.pkey_column;
    END update_parent_children;
    null

  • Migrating MySQL5 database to Oracle 10g - refrential integrity constraints

    On migrating MySQL5 database to oracle, referential integrity constraints are not migrated to Oracle. Capture stage shows it has captured the constraints but constraints are missing from the Oracle Model. Is this a bug? If not, what I need to do to get constraints migrated.

    Check out *URGENT* Does Oracle SQL Developer able to migrate tables relationships?
    K.

  • Not saving the data in two tables

    Hello,
    its my production problem, i have an update form where you can update the records and these
    records will sit in the temp tables until the final approval from the supervisor.
    In this update form i have two table where i am saving the data one is dup_emp to save the
    officer data and another is the dup_address to save the officer where he worked data.
    in this form address form is pop up screen where you can update and gets back to the original
    form where you can see all the other fields. my problem is if a user hit the cancel button on
    address form example the user doesnt want to update any information on that screen so user
    cancel that screen, and comes to the other screen where the user makes the changes to the
    appropriate fields and hits the SAVE button. in this case its saving only to the dup_emp table
    data not the address data from the address form to dup_address table for the same record.
    if the user cancels in both the screens cancel button it should delete the record from both the
    tables but cancel in form and saves in another form it should save the record in both the
    tables.
    here is my code from both cancel buttons from both the forms.
    this is code is from address form cancel button.
    delete from dup_address
    where address_id=:address_id
    and parent_table_name='emp';
    commit;
    CLEAR_BLOCK;
    go_block('DUP_EMP');
    This code is from dup form of the cancel button
    declare
    temp_address_id varchar2 (12);
    begin
    delete from dup_emp
    where secondemp_id =:dup_emp.secondemp_id;
    delete from dup_address
    where parent_t_id=:global.secondemp
    and parent_table_name='emp';
    commit;
    clear_block;
    go_block('secondaryemp');
    END;

    Hi,
    As Aravind mentioned, it's nothing related to workflow. You have to find a BADI in tcode PA30 that could be used after the infotype is updated. So, you can use FM SAVE_TEXT.
    Regards,

Maybe you are looking for

  • Will there ever be a fix for Animated Gifs  OS 10.5.8

    I realize this extremely stupid bug which has/had been around for many years was apparently fixed in 10.6, but that upgrade is simply not an option for me (as, 10.6 will not install on this machine.) the problem is very well known (and many years old

  • POE device flapping on switch access port

    I have a switch at a remote office.  I have a Cisco 2851 Router and two cisco 3650 POE switches.  I also have three Aruba 105 POE APs. Two are plugged into one switch, and one into another. Yesterday we had a power issue that caused all of the equipm

  • I want to know abt electronic personalization of java card

    i want to know abt electronic personalization of java card (My card is Gemalto TOPDL v2)

  • Can I change language?

    I downloaded tv series while on holiday in Italy but it is in wrong language. can I change language?

  • Appleidauthagent on startup.

    So I did reinstall my Mac through system recovery a long time ago. When it was finished I had to set it up as a new Mac (including adding a root user) After I logged in on my own account I deleted that extra user. But since then a screen randomly pop