Listing foreign keys with non matching column definitions

Dear All,
I seen an entry in DBA weeky activities s that "Listing foreign keys with non matching column definitions" . What is meant by that?. How to pick up that?
Shiju

I seen an entry in DBA weeky activities s that
"Listing foreign keys with non matching column
definitions" . What is meant by that?. How to pick up
that?Most probably find columns which are part of foreign keys, but their respective primary key column have different length (AFAIK data type cannot be different).
Data dictionary can help you in that, I'll give you hints where to look at:
user/all/dba_constraints - foreign and primary keys
user/all/dba_cons_columns - columns which are part of constraints
user/all/dba_tab_columns - column definitions of tables
However creating query from these data dictionary views could be a nice task for you :)
Gints Plivna
http://www.gplivna.eu

Similar Messages

  • Foreign key constraint on multi-column primary key accepts 1 empty column!?

    Hi, we have a reference table with a two-column primary key. In the child table there is a non-mandatory foreign key constraint to this table. So if both child columns are null it's ok too. But now we see that if one of the two child table columns that build up the foreign key is null, the other column can have any (non-existant in the master-tabel) value you like!? That does not make sense.
    Can anyone explain this to me???
    Regards, Paul.

    Paul, I believe that this is in accordance to the ANSI SQL standard requirement for the treatment of nulls in a multi-column FK. In any case Oracle specifically states this is the way FK work From the 10 Concepts manual, Ch 21 Data Integrity, topic Nulls and Foreign Keys:
    The relational model permits the value of foreign keys either to match the referenced primary or unique key value, or be null. If any column of a composite foreign key is null, then the non-null portions of the key do not have to match any corresponding portion of a parent key. <<HTH -- Mark D Powell --

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • Drop foreign keys and recreate foreign keys with on delete cascade dymanica

    I need to drop foreign keys and recreate foreign keys with on delete cascade dymanically via a script. Does anyone have a script available?

    You could also disable the integrity contraints.
    SET PAGESIZE 0
    SET FEEDBACK OFF
    SET PAUSE OFF
    -- create a disable script
    SPOOL do_disable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10) ||
           'DISABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    select 'alter trigger '
           || trigger_name
            || ' disable;'
      from user_triggers
    where status = 'ENABLED'
    SPOOL OFF
    -- now create a enable script as well
    SPOOL do_enable.sql
    SELECT 'ALTER TABLE '
           || table_name
            || chr(10)
            || 'ENABLE CONSTRAINT '
            || constraint_name
            || ';'
      FROM user_constraints
    WHERE constraint_type = 'R'
       AND status = 'ENABLED'
    SELECT 'ALTER trigger '
           || trigger_name
            || ' ENABLE;'
      FROM user_triggers
    WHERE status = 'ENABLED'
    SPOOL OFF
    SET FEEDBACK ONif you run this script on a TESTdatabase you will end up with a do_disable.sql and a do_enable.sql script on youre local directory.
    Running do disable will disable all the currently enabled triggers and contraints.
    Running do_enable.sql will enable the previously disables triggers and contraints.
    be sure to test before executing this on a real live production database.
    Make sure you have a good backup!

  • Issue with non calculated column in a fact table

    Hi All,
    With 3 facts(Fact1,Fact2,Fact3) and 2 Confirmed Dimensions my joins work fine in Criteria when I include All calculated columns from facts. If I try to include a non calculated column from Fact1(Which is a number Data type) Columns from Fact2 and Fact3 show Null values. I know it is not recommended to include dimension columns in fact , does OBIEE not support Number type non calculated columns as well? Is there any work around that I can bring in my non calculated column from Fact and still get results for other fact columns.Iam at 11.1.1.7 of OBIEE
    Let me know if Iam not clear.
    Your help is much Appreciated.
    Thanks,
    Vineela.

    i would like to add 2 fields into my fact tables - LOAD ID (populated by a sequence during each load) and LOAD DATE.
    as these fields are not related to any reporting dimensions, it is still possible to add them in OWB ? the fact wizard always ask for a foreign key to a dimension ...
    Duncan,
    If you want to add non dimensional attributes to a fact by using OWB, you can create additional measures to it and use them as attributes.
    Igor

  • How do I deal with "non match"pictures?

    I have a folder that is supposed to keep pictures of my wife only. However these pictures have been joined by others that bear tags for other folders.
    In the left top corner of these "trespassing" pictures there is a circle with a line through it titled "non match"
    How can I stop this happening please?
    Cliff

    Cliffie,
    Make sure that youve deselected Options > Show results that do not match in the Find bar (the third line from the top of the Organizer screen). If that doesnt work, then read this thread:
    John Rolfe Ellis, "Exact match" #1, 30 Apr 2008 11:55 pm

  • Problem with non-matching records

    I have 3 tables - TBL1 is a list of Conditions; TBL2 contains collected data; and TBL3 contains referenced details on the data in TBL2.
    TBL2 contains some matching values from TBL1.
    Ex.
    TBL1
    Condition
    01 Test A
    02 Test B
    03 Test C
    TBL2
    Name, Condition, Value
    Host101, 01 Test A, Yes
    Host101, 02 Test B, No
    Host101, 03 Test C, Yes
    Host102, 01 Test A, No
    Host102, 03 Test C, Yes
    I have them linked TBL1 Left Outer to TBL2 and TBL2 Left Outer to TBL3.
    My desire is to get the complete list of Conditions in TBL1 for each record in TBL2, even where there is no matching TBL1 value in TBL2 - so the report results of the above table data would be:
    Host101
    01 Test A     Yes
    02 Test B      No
    03 Test C      Yes
    Host102
    01 Test A     No
    02 Test B
    03 Test C      Yes
    So even though there is no data returned in TBL2 for Host102, 02 Test B, the record for that entry in TBL1 is still returned in the report.
    Currently I have the report structured as follows -
    {TBL2 Name}
    TBL1 Condition     TBL2 Value
    Seems quite simple, but I must be missing something somewhere, as I am only able to get the data where the records match, so, in the example above, I am getting only -
    Host102
    01 Test A     No
    03 Test C      Yes
    Any assistance would be much appreciated.  Thanks!
    Also, I tried doing a simple new report using just TBL1 & TBL2 and still get the same results (also tried a Full Outer join as well).
    Frustrating .......
    Edited by: Dragon77 on May 17, 2010 2:05 PM

    As I said, I have even tried removing TBL3 to make things even simpler - TBL1 & TBL2 Left Outer joined on the common field.
    I have tried every combination that I can think of.  We're talking on 4 fields in the report -
    Group Header 1 = {TBL2 Name}
    Group 2 = {TBL2 Unique Field}
    Detail = TBL1 Condition     TBL2 Value
    Group Header 1 = {TBL2 Name}
    Group 2 = {TBL2 Unique Field}
    Group 3 = {TBL1 Condition}     {TBL2 Value}
    Detail Suppressed
    No matter what I try, I only get matching records.
    I've gone so far as to just have the minimal 3 fields
    Group Header 1 = {TBL2 Name}
    Group 2 = {TBL2 Unique Field}
    Detail = TBL1 Condition
    Group Header 1 = {TBL2 Name}
    Group 2 = {TBL2 Unique Field}
    Group 3 = {TBL1 Condition}
    Detail Suppressed
    The tables only have the 1 field in comon {TBL1, TBL2 - Condition)
    This just doesn't make sense.  {TBL1 Condition} should have ALL of its entries returned along with any matching records from {TBL2 Condition} - not just where they are equal.

  • Select Query with diagonally  matching columns

    hi
    the following is the table struncture and insert statements
    create table emp_trans values (empno number , emptran_no number, prev_amount number, current_amount number)
    insert into emp_trans values(102,109,0,20);
    insert into emp_trans values(102,119,10,20);
    insert into emp_trans values(102,129,20,30);
    insert into emp_trans values(102,139,30,0);
    insert into emp_trans  values(201,101,0,20);
    insert into emp_trans values(201,110,20,30);
    insert into emp_trans values(201,120,0,30);
    insert into emp_trans values(201,130,30,20);
    insert into emp_trans values(201,140,0,20);In the table we can see some mappings as follows
    The data is on empno basis.
    we have 2 employees with empno 201 and 102 . Each empno has different emptrans_no. Need not be in an sequence.
    we need to select the set of records where prev_amount column matches with the current_amount column values for
    the previous record for every individual empno.
    prior to that the following basic select statement can be considered
    select * from emp_trans  order by empno , emptran_nofor ex:
    emp no 102 emptran_no 129 prev_amount column having values of 20 matches with the current_amount column having values 20
    with emptran_no 119.
    for empno 201 with emptran_no 110 we can see the prev_amount column having value 20 matched with current_account column havig values of 20
    of previous emptran_no 101 for the same empno 201.
    something like we need to see the diagnally mathced values.
    Any help on such query most welcome.
    Regards,

    Hi,
    sri wrote:
    Hi
    A small Change required
    For empno 201 we need to display
    EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
    102 129 20 30
    102 139 30 0
    201 *120* 20 30
    201 130 30 20
    rathe than
    EMPNO EMPTRAN_NO PREV_AMOUNT CURRENT_AMOUNT
    102 129 20 30
    102 139 30 0
    201 *110* 20 30
    201 130 30 20Always explain how you get the results you want. Otherwise, the solution that works on your sample data won't necessarily work on your real data.
    Given that the data for empno=201 is:
    insert into emp_trans values (201, 101,  0, 20);
    insert into emp_trans values (201, 110, 20, 30);
    insert into emp_trans values (201, 120,  0, 30);
    insert into emp_trans values (201, 130, 30, 20);
    insert into emp_trans values (201, 140,  0, 20);Why do you want the row with emptrn_no=120, and not the row with emptran_no=110?
    If you want the row with emptran_no=120, why don't you want the row with emptran_no=101?
    If you want the row with emptran_no=130, why don't you want the row with emptran_no=110?
    can u please let me know the way you formatted the code for the query and sample output This site noramlly compresses whitespace.
    Whenever you post formatted text (such as query results) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Report: list of computers with out dated antivirus definitions

     
      Is there a report in SCCM to list all machines with outdated antivirus (SC End Point Protection) ?
      I believe SCCM take out such machine out of network through security center information  even if third part antivirus is installed.
      But can we get that as report as well ? list of computers
    Shahid Roofi

    Yes, I know this is an old post, but I’m trying to clean them up.
    I would start by looking at the built-in report found within the Endpoint Protection SSRS folder.
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Doc. create by MIRO in foreign curr. with non-deductible tax

    Hello everyone,
    when I create a doc. by MIRO with a foreign currency and a partially non-deductible tax code I see that the field BSEG-TXBHW of position type W is not filled with any amount.
    Somebody has already faced with this problem?
    My bseg look like this:
    BUZEI   KOART DMBTR   WRBTR                                                       TXBHW   TXBFW
                   K           864,12    1.200,00       0,00      1.200,00     USD         0,00         0,00
    W           S           862,68    1.198,00       0,00         862,68      EUR         0,00         0,00
    T            S                1,44            2,00       0,00              2,00     USD          0,00         0,00

    Ok

  • List - Display Name with Presence (1st column) Display User ID (2nd Column)

    I have a simple list and one column titled Member and it is set as a Person field. My goal is to also have the corresponding Member.ID (ex 9012) also available as a second column so that when a user enters a name, it will auto populate the ID column.
    Put another way, two columns. Col A Member (Name with Presence) Colm B Member (ID) Can this be done without coding? I need these two columns for export into Access.
    Attempts thus far:
    1. Attempted to create a second column and have it set as lookup, pointing to the Member (Name with Presence) Column and it wont see it. -Fail
    2. Attempted to create a second column and have it set as calculated, pointing to the Member (Name with Presence) Column and it won't see it. -Fail
    3. Created a new page, inserted a data view. This allows me to display Member.ID but if I open/export to Access the column is not displayed. Same occurs with Excel. It's like it does not exist. -Fail
      Edit: Update, I've changed from User ID # to User Account.

    Hi  ,
    According to your description, my understanding is that you want to auto populate the Member ID column.
    For achieving your demand, you can create an auto incrementing number  using SharePoint workflow.
    For more information, you can refer to these blogs:
    http://dlairman.wordpress.com/2011/01/10/add-a-unique-auto-incrementing-column-to-a-sharepoint-list/
    https://www.nothingbutsharepoint.com/sites/eusp/pages/sharepoint-how-to-create-an-auto-incrementing-number-field-for-use-in-a-custom-id-part-1.aspx
    Also you can create an auto incrementing number using infopath:
    http://claytoncobb.wordpress.com/2009/06/15/auto-numbering-infopath-forms/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Join rows from 2 tables with non-matching numeric intervals

    Hi,
    Could you please help me with the following:
    I have 2 tables - [Coal_Samples] and [Coal Type] Which I have pasted below. I want to create a single result set that matches as closley as possible [Coal Type].Coal_Type to the interval between [Coal_Samples].mfrom and [Coal_Samples].mto. I would have
    [Coal_Samples] as the primary table using a left outer join.
    The problem is that the intervals [Coal_Samples].mfrom do not match [Coal Type].mfrom and [Coal_Samples].mto does not match [Coal Type].mto. I want to match the [Coal_Samples] intervals ([Coal_Samples].mfrom-[Coal_Samples].mto) as closely as possible to
    the [Coal_Type].Coal_Type field.
    I have been able to acheive this in excel using a VLOOKUP statement - but I want to know how to do this with and SQL Script without duplicating the rows based in [Coal_Samples].mfrom-[Coal_Samples].mto interval. 
    COAL SAMPLES TABLE
    ID
    mFrom
    mTo
    SAMPLE NUMBER
    AD261
    57
    57.5
    SAMPLE_001
    AD261
    57.5
    58
    SAMPLE_002
    AD261
    58
    59
    SAMPLE_003
    AD261
    59
    60
    SAMPLE_004
    AD261
    60
    61
    SAMPLE_005
    AD261
    61
    62
    SAMPLE_006
    AD261
    62
    63
    SAMPLE_007
    AD261
    63
    64
    SAMPLE_008
    AD261
    64
    65
    SAMPLE_009
    AD261
    65
    66
    SAMPLE_010
    AD261
    66
    67
    SAMPLE_011
    AD261
    67
    68
    SAMPLE_012
    AD261
    68
    69
    SAMPLE_013
    AD261
    69
    70
    SAMPLE_014
    AD261
    70
    71
    SAMPLE_015
    AD261
    71
    72
    SAMPLE_016
    AD261
    72
    73
    SAMPLE_017
    AD261
    73
    74
    SAMPLE_018
    AD261
    74
    75
    SAMPLE_019
    AD261
    75
    76
    SAMPLE_020
    AD261
    76
    77
    SAMPLE_021
    AD261
    77
    78
    SAMPLE_022
    AD261
    78
    79
    SAMPLE_023
    COAL   TYPE TABLE
    ID
    Type_mFrom
    Type__mTo
    COAL TYPE
    AD261
    57
    68.6
    BROWN COAL
    AD261
    68.6
    75
    GREY COAL
    AD261
    75
    78.2
    BLACK COAL
    AD261
    78.2
    79.2
    BLACK COAL
    Example   RESULT SET
    ID
    mFrom
    mTo
    DOMINANT_COAL TYPE
    AD261
    57
    57.5
    BROWN COAL
    AD261
    57.5
    58
    BROWN COAL
    AD261
    58
    59
    BROWN COAL
    AD261
    59
    60
    BROWN COAL
    AD261
    60
    61
    BROWN COAL
    AD261
    61
    62
    BROWN COAL
    AD261
    62
    63
    BROWN COAL
    AD261
    63
    64
    BROWN COAL
    AD261
    64
    65
    BROWN COAL
    AD261
    65
    66
    BROWN COAL
    AD261
    66
    67
    BROWN COAL
    AD261
    67
    68
    BROWN COAL
    AD261
    68
    69
    BROWN COAL
    AD261
    69
    70
    GREY COAL
    AD261
    70
    71
    GREY COAL
    AD261
    71
    72
    GREY COAL
    AD261
    72
    73
    GREY COAL
    AD261
    73
    74
    GREY COAL
    AD261
    74
    75
    GREY COAL
    AD261
    75
    76
    BLACK COAL
    AD261
    75
    76
    BLACK COAL
    AD261
    76
    77
    BLACK COAL
    AD261
    77
    78
    BLACK COAL
    AD261
    78
    79
    BLACK COAL
    Can you please help with the logic of this query?
    Thanks very much.

    Well, here is the beginning of the solution:
    ;with cte as (select S.*, T.[Coal Type] as [Dominant_Coal],
    case when 
    T.m_from between S.m_from and S.m_to
    AND T.m_to between S.m_from and S.m_to then 0
    when T.m_from between S.m_from and S.m_to then t.m_from - S.m_from
    else S.m_to - T.m_to end as [Diff]
    from Coal_Samples S LEFT JOIN Coal_Type T
    ON T.m_from between S.m_from and S.m_to
    OR T.m_to between S.m_from and S.m_to),
    cte1 as (select *, row_number() over (partition by cte.ID order by Diff) as Rn
    from cte)
    select * from cte1 where Rn = 1 -- attempt to get best match
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Foreign Key join between two columns in a dimension to one column in Fact

    Hi,
    I have a requirement to join two columns in a Dimension to the same column in the fact.
    My reports contains columns from this dimension and will need to use both the joins to get the correct values. So I am not sure if I create an alias to join the second column, if that will be output incorrect values.
    How can we achieve this so that I can still use columns from the dimension and still run both the joins in my SQL eventually.
    Dimension
    Column 1
    Column2
    Fact
    Column 3
    Need to map Column1--->Column 3 and Column2 -----> Column 3
    Thanks

    I put it in Dimension and dimension extension scenario with a fact
    The possible scenarios are:
    1) Column1--->Column 3 and Column2 -----> Column 3
    Both Column1 and Column2 have their own logical tables in BMM
    2)
    Column1--->Column 3
    Column1--->Column2
    In this case You have Logical table with 2 different sources Column1 and Column2 using column mapping.
    you can go for multiple logical sources in this case, based on column selection tables in the join condition

  • How to use iPhone in foreign country with non US career?

    I want to pre-order iPhone 5 from this internet site (US), but I live in Slovenia. Am I going to be able to use my phone with slovenian career? if not, how could I be able to do that that? I heard something abou unlocking the phone, but I don't know where, how and who could/should do that?

    In order to be able to order from the U.S. Online Store you need to have a U.S. credit card and the device has to be shipped to a U.S. address.

  • FK Constraints with nonmatching column definitions

    Hello,
    I ran a healthcheck with TOAD and he reported some foreign keys with nonmatching column definitions:
    ! Constraint : HERCULES.LBS_VAL_FK
    ! On Table : HERCULES.LOONBESLAG_SCHULDEISEN
    ! Columns : VAL_CD VARCHAR2 (5)
    ! To Table : HERCULES.VALUTA
    ! Columns : CODE VARCHAR2 (3)
    It also mentions that this causes poor performance because of data conversion.
    But, varchar2 means that each column has a variable length and this length is stored somewhere. So the value of VAL_CD and CODE will be stored in exactly the same way. No data conversion, no poor performance. Right?
    Or am I missing something here?
    Thanks for all the feedback.
    Rik

    I'm quite sure data type conversion doesn't take place here. However the very idea of different types for the PK-FK columns is nonsense, because you cannot fully use this VARCHAR2 (5) column in this case anyway. OK I'm not speaking about deferred constraints :)
    Gints Plivna
    http://www.gplivna.eu

Maybe you are looking for

  • My 2010 Macbook Pro won't turn on...

    I left my Macbook Pro alone for a moment and when I had returned it had shut down on it's own and wouldn't turn back on. (MagSafe unattached) 1. It will not turn on.  2. Battery Indicator - When pressed displays nothing.  Computer is super, super dea

  • Mac app store update indicated as installed

    The Mac App Store tells me there's an update available for one of my applications, however, the install button is disabled and indicates that the new version of the app is already installed. The version number of the app (About...) shows v120...., th

  • Openoffice api converted pdf not loading using acrobat viewer

    While i used AcrobatFaxProducer of RFAX component java api which in turn uses Acrobat.jar and MRJToolkit to support pdf documents to fax. but you know while I tried to fax a pdf document which is being converted from word file using openoffice api, I

  • Plug Ins and 64 Bit/32 Bit

    I have just shifted to 64 bit Win7 with both 64 bit and 32 bit Photoshop installed.  I have been a happy user of Nik plug ins, but they are not compatible with 64 bit Photoshop (though Viveza 2 seems to haveinstalled in both versions).  I have confir

  • TIme Machine verification issue (Drobo and Airport Extreme)

    Hello. I recently purchased a Drobo (1st gen, off ebay) to replace a 1TB WD MyBook I was using as a Time Machine backup and Media Server. The Drobo is connected to an Airport Extreme base station over USB 2.0. My Mac is connected by ethernet to the A