Find missing referential constraints

I have a master table that is referenced by many other tables. Unfortunately, many of these child tables have been created without the necessary referential constraint to the parent. How can I easily identify these tables?
The code would be like
select table_name
from tables
where table_column like '%master_column'
and not exists referential constraint on this table_column to the master_table
Has anyone had to do this in the past - do you have an example script?
Thanks
Richard

Here is something I cobbled together that seems to work - its not pretty though...
SELECT *
FROM DBA_TAB_COLUMNS atc,
DBA_OBJECTS allo
WHERE (UPPER(atc.column_name) LIKE :column_name)
AND (atc.owner IN (:owner))
AND (allo.object_name = atc.table_name)
AND (allo.owner = atc.owner)
AND (allo.object_type IN ('TABLE', 'VIEW', 'CLUSTER', 'MATERIALIZED VIEW', 'UNDEFINED'))
AND NOT EXISTS
(SELECT *
FROM (SELECT AO.NAME TABLE_NAME,
AU.NAME OWNER,
BCN.NAME CONSTRAINT_NAME,
DECODE(ac.TYPE#, 4,
DECODE(ac.refact, 1, 'CASCADE', 2, 'SET NULL', 'NO ACTION'),
NULL) delete_rule,
BO.NAME TN, BU.NAME R_OWNER
FROM SYS.CDEF$ BC, SYS.CON$ BCN, SYS.OBJ$ BO, SYS.USER$ BU,
SYS.CON$ BRC, SYS.USER$ BRU, SYS.OBJ$ BRO,
SYS.CDEF$ AC, SYS.CON$ ACN, SYS.OBJ$ AO, SYS.USER$ AU
WHERE BC.CON# = BCN.CON#
AND BC.OBJ# = BO.OBJ#
AND BO.OWNER# = BU.USER#
AND BC.RCON# = BRC.CON#(+)
AND BRC.OWNER# = BRU.USER#(+)
AND BC.ROBJ# = BRO.OBJ#(+)
AND AC.CON# = BC.RCON#
AND AC.CON# = ACN.CON#
AND AO.OBJ# = AC.OBJ#
AND AO.OWNER# = AU.USER#
AND AC.TYPE# IN (2,3)) A,
DBA_CONS_COLUMNS B
WHERE B.TABLE_NAME = A.TN
AND B.CONSTRAINT_NAME = A.CONSTRAINT_NAME
AND B.OWNER = A.R_OWNER
AND b.table_name = atc.table_name
AND b.owner = atc.owner)
Richard

Similar Messages

  • "Open VI Reference" Option "Prompt user to find missing subVIs"

    I am using "Open VI Reference" to dynamically load a VI. For the "option" control of the "Open VI Reference" node, I pass "0x10" or "10" in hexadecimal, which supposedly "prompt user to find missing subVIs." Nevertheless, I don't get a prompt message dialog when I intentionally pass an invalid or missing VI path. Instead I just get an Error Code 7. What does this option "Prompt user..." suppose to do?

    Make sure you set the properties on the integer input into the “options” control to the “Open VI Reference” to be a Hexadecimal format (right-click on the “options” control input, select Format and Precision…, then select Hexadecimal). Now, if you re-run your VI and wire in a VI with a missing subVI, the Open VI Reference will appear with a dialog that will prompt you to browse to the missing subVI. This is exactly the same message LabVIEW displays when it attempts to open a VI and cannot find its subVIs.
    I’ve attached a simple example program to demonstrate. Enter the path to the “number extractor.vi” as the VI to open. You should see a dialog prompt appear asking for the “Search 1D Array – Complete.vi”.
    Hope this helps!
    Attachments:
    openVIRefExample.zip ‏20 KB

  • Finding missed sequence numbers and rows from a fact table

    Finding missed sequence numbers and rows from a fact table
    Hi
    I am working on an OLAP date cube with the following schema:
    As you can see there is a fact transaction with two dimensions called cardNumber and Sequence. Card dimension contains about three million card numbers. 
    Sequence dimension contains a sequence number from 0 to 255. Fact transaction contains about 400 million transactions of those cards.
    Each transaction has a sequence number in 0 to 255 ranges. If sequence number of transactions of a card reaches to 255 the next transaction would get 0 as a sequence number.
    For example if a card has 1000 transactions then sequence numbers are as follows;
    Transaction 1 to transaction 256 with sequences from 0 to 255
    Transaction 257 to transaction 512 with sequences from 0 to 255
    Transaction 513 to transaction 768 with sequences from 0 to 255
    Transaction 769 to transaction 1000 with sequences from 0 to 231
    The problem is that:
    Sometimes there are several missed transactions. For example instead of sequence from 0 to 255, sequences are from 0 to 150 and then from 160 to 255. Here 10 transactions have been missed.
    How can I find all missed transactions of all cards with a MDX QUERY?
    I really appreciate for helps

    Thank you Liao
    I need to find missed numbers, In this scenario I want the query to tell the missed numbers are: 151,152,153,154,155,156,157,158,159
    Relative transactions are also missed, so I think it is impossible to get them by your MDX query
    Suppose this:
    date
    time
    sequence
    20140701
    23:22:00
    149
    20140701
    23:44:00
    150
    20140702
    8:30:00
    160
    20140702
    9:30:00
    161
    20140702
    11:30:00
    162
    20140702
    11:45:00
    163
    As you can see the sequence number of the last transaction at the 20140701 is 150
    We expecting that the first transaction of the next day should be 151 but it is 160. Those 10 transactions are totally missed and we just need to
    find missed sequence numbers

  • Incorrect order for referential constraints in Export

    When multiple tables are selected to export, the created file places the ALTER TABLE statements for the Referential Constraints immediately after the creation of the source table. Unfortunately, most of the time this will mean that the referenced table has not yet been created and the statement will fail.
    All referential constraints should be created as a separate block of statements at the end of the file rather than table by table where errors will occur if the script is simply run.

    I managed to resolve the issue by un-commenting below lines( they were commented in std though) -
    XDECI FILL IT & XDECI FILL RT

  • Property or method to find missing fonts...

    Hi Everyone,
    Is there any direct property or method to find missing fonts in EPS doucments in Illustrator CS4 like we do in InDesign. I have tried this by doing comparison of document fonts and application fonts to get missing fonts but it won't work.
    Any help would be appreciatable. Thanks in advance.
    Regards
    Thiyagu

    Have you tried a search of this forum… Im sure I posted a work around to this… The simple answer is NO not in the Illustrator DOM you can however read the file as text and the stuff you want is in the Illustrator file comments…

  • Is there not an easier way to find missing songs?

    Is there a smarter way to find missing songs and albums besides having to go through each one individually? Some kind of batch process would be nice...
    How do you guys efficiently find missing songs or albums?

    don't you just love the way Apple answers your questions in this forum?

  • Finding missing photos when drive letter has changed

    I have over 30,000 missing photos because LR only recognizes drive letters not names.  All my drives have a master "Image" directory with folders and subfolders.  Going to the LR online directory with name change and right clicking images and finding folder location does not work.  LR does not recognize folders or subfolders in the drive with a name change.  Usually none of the folder names are high lighted. By going to the "Missing Photographs" in the catalog menu and searching by file name I can find individual files but with over 30k missing files, this approach is not practical. I have an HP computer with Windows 7 and LR 5.7.  How do I find the photos?

    I think the most straightforward way to sort this out is:
    1. Plug in all of your external drives.  From the screen shots, it looks like you have at most 5 external drives of interest, 2 that are currently online and 3 that are disconnected.  (I'm not counting the one external drive letter that has just one photo on it.)  How many external drives do you actually have?
    2. If you don't have enough USB ports, order a $12 USB hub from Amazon.
    3. Make sure the entire folder hierarchy for each drive is showing in the Folders pane as described here. When you're done, each drive in the Folders pane should have a top-level folder labeled with a drive letter (as with your F: drive in the screenshot above).
    4. Expand the entire folder hierarchy on each drive in the Folders pane by clicking the arrows to the left of the folder.
    5. For each drive, find one or more folders in its hierarchy that are closest to the top that have a "?" on them.  It may be the root folder labeled with the drive letter (e.g. "F:"), or it may be folders below the root folder.   For each such folder with a "?", right-click it and select Find Missing Folder.  That folder should be somewhere on one of the drives.  Use Windows File Explorer to help find where it is.
    6. When you're done with step 5, you should have located all missing folders and told LR where they are currently located.  But you may have missed some.   Do Library > Find All Missing Photos.
    7. Pick a photo from step 6.  Right-click it and do Go To Folder In Library.  If the folder in the Folder pane is marked with a "?", right-click it and do Find Missing Folder.   Otherwise, click the "!" on the photo and then click Locate.  Use Windows File Explorer to help find the missing photo by filename, if necessary.  Repeat until there are no more missing photos.
    8. Going forward, try to keep all your external drives connected.  To minimize drive-letter confusion in the future, rename the drive letters of the existing external drives to start from the end of the alphabet, changing each drive letter as described here.   When you change a drive letter, you'll need to re-locate its root folder as described in steps 3-5.   (Windows tends to use drive letters from C onward.)

  • LR5 Find missing photos - search nearby won't work consistently

    LR5 seems to work inconsistently when locating missing photos and selecting "find nearby photos".
    It has succeeded in finding nearby files but now will only locate one file at a time....a very annoying and time consuming exercise!
    Any suggestions please?

    Hmm, I'm still not sure about your situation.  But if the entire folder was missing (before you started finding individual pics), then it's easy to find the whole folder.  You can see if the folder is missing by looking in the Folders pane on the left -- it will have a "?" on it:
    Right-click on the folder and select Find Missing Folder.

  • Referential constraints on XMLType tables

    Hi all,
    I'm trying to create an XMLType table with a foreign key that references another XMLType table. Shouldn't be a big deal, i thought.
    CREATE TABLE datasets (
    ID NUMBER,
    XML XMLTYPE )
    XMLTYPE COLUMN XML XMLSCHEMA "dataset_schema.xsd" ELEMENT "root";
    CREATE TABLE categories OF XMLTYPE XMLSCHEMA "categories.xsd" ELEMENT "categories";
    ALTER TABLE datasets
    2 ADD CONSTRAINT dataset_isvalid
    3 FOREIGN KEY(XML.XMLDATA."dataset"."metaInformation"."referenceFunction"."category")
    4 REFERENCES categories(XMLDATA."category"."name");
    FOREIGN KEY(XML.XMLDATA."dataset"."metaInformation"."referenceFunction"."category")
    ERROR at line 3:
    ORA-22809: nonexistent attribute
    I've then been reading through the postings regarding foreign key and unique constraints and i've managed to understand the concept of nested tables. To my dismay, trying to establish referential constraints my nested tables would throw an ORA-30730 stating this cannot be done.
    I've simplified my schemas a little so it won't get to complicated: one table will store datasets and the other will hold category names.
    The schema for the categories is
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- schema for categories -->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:element name="categories">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="category" type="categoryType" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
         <xs:complexType name="categoryType">
              <xs:sequence>
                   <xs:element name="subCategory" type="subCategoryType" maxOccurs="unbounded"/>
              </xs:sequence>
              <xs:attribute name="name" type="xs:string" use="required"/>
              <xs:attribute name="localName" type="xs:string" use="required"/>
              <xs:attribute name="type" type="xs:byte" use="required"/>
         </xs:complexType>
         <xs:complexType name="subCategoryType">
              <xs:attribute name="name" type="xs:string" use="required"/>
              <xs:attribute name="localName" type="xs:string" use="required"/>
         </xs:complexType>
    </xs:schema>
    and the schema for the dataset table is
    <?xml version="1.0" encoding="UTF-8"?>
    <!- dataset schema-->
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
         <xs:complexType name="datasetType">
              <xs:sequence>
                   <xs:element name="metaInformation" type="metaInformationType"/>
                   <xs:element ref="otherInformation"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="metaInformationType">
              <xs:sequence>
                   <xs:element name="referenceFunction" type="referenceFunctionType"/>
              </xs:sequence>
         </xs:complexType>
         <xs:element name="otherInformation" type="xs:string"/>
         <xs:complexType name="referenceFunctionType">
              <xs:attribute name="name" type="xs:string" use="required"/>
              <xs:attribute name="category" type="xs:string" use="required"/>
              <xs:attribute name="subCategory" type="xs:string" use="required"/>
         </xs:complexType>
         <xs:element name="root">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="dataset" type="datasetType" maxOccurs="unbounded"/>
                   </xs:sequence>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Now I want to define the referenceFunction/@category attribute of the dataset to be a foreign key to the categories table. Is it possible at all to do that with constraints? After failing with the nested table approach I really do not have any clue I would greatly appreciate any hints.
    Thanks,
    oli

    Nested tables do not currently support referential integrity.
    Foreign Keys on elements with maxOccurs > 0

  • Updating/Find Missing *Drive* Query

    Good day to you all
    I'm looking for a way to apply the "Find Missing Folder.." function to the actual drive. Essentially using the Drive letter as the parent "folder" to sync all subfolders and update all the image paths.
    The scenario;
    I had all my photos on a local drive "W:".
    They are now all on a network drive - we'll call this \\NAS\Photos (where photos is the share name on the network drive)
    I can manually go through the "missing" folders from W: in the left pane of the library and "Find Missing Folders.." one at a time. This works.
    However, I have about 100 folders so this is very time consuming.
    The folder structure is exactly the same, what I would like to do is update the DRIVE path so I can preserve all of the LR edits.
    Any ideas?
    TIA

    So what exactly are you doing....are you trying to relink one of the missing folders to the parent folder on the NAS? Is the parent folder showing in the Folders Panel in Lightroom's Library module? If it is, that's the folder you should relink to the equivalent parent on the NAS.
    If, however, the parent folder is NOT showing in the Folders Panel, then right-click on any of the "missing" folders and select "Show Parent Folder"....that should add the parent folder to the folders panel, so that you can then relink with a single "Find Missing Folder" command (the ability to show a parent folder for missing folders was a new feature in LR4, you couldn't do that in previous versions).

  • Finding Missing Time Interval in SQL

    All 
     Need help with SQL to find Missing Time Interval. 
    My query returns data as given below  
    Data1
     Column      StartTime    EndTime
    =======   =======   ======= 
    T2               9:00          18:00T3               20:00         23:00 
    Data2
     Column      StartTime    EndTime
    =======   =======   ======= T1               15:00          20:00
    T3               20:00          07:00 
    Take above output, I want to find Time Not on my Data in 24 hours from First StartTime on each Data Set.
    Example: Data1
    First StartTime: 9:00 AM (T2 record)
    Add 24 hours, which will be 9:00AM Next day.
    Expected Result to get missing time interval for Data1
    18:00 - 20:00
    23:00 - 9:00 (next day)
    For Data2 Expected result
    7:00 - 15:00 Next Day
    Database version: 11g
    Anyone come across to calculate missing time interval? Can I use PL/SQL for this like pipeline function?
    Any help/directions/references I highly appreciate.
    Thanks in advance.
    Karth

    One way of finding Missing Intervals:
    alter session set nls_date_format = 'DD-Mon-YYYY HH24:MI:SS';
    with data as
      select to_date('28-Jun-2013 09:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 18:00', 'DD-Mon-YYYY HH24:MI') end_time from dual union all
      select to_date('28-Jun-2013 20:00', 'DD-Mon-YYYY HH24:MI') start_time, to_date('28-Jun-2013 23:00', 'DD-Mon-YYYY HH24:MI') end_time from dual
    select start_time, end_time,
           case when lead(to_char(start_time, 'HH24'), 1, (select min(to_char(start_time, 'HH24')) from data)) over (order by to_char(start_time, 'HH24')) not between to_char(start_time, 'HH24') and to_char(end_time, 'HH24')
                  then to_char(end_time, 'HH24:MI') || ' - ' || lead(to_char(start_time, 'HH24:MI'), 1, (select min(to_char(start_time, 'HH24:MI')) from data)) over (order by to_char(start_time, 'HH24:MI'))
                else
                  null
           end period
      from data
    START_TIME                END_TIME                  PERIOD      
    28-Jun-2013 09:00:00      28-Jun-2013 18:00:00      18:00 - 20:00
    28-Jun-2013 20:00:00      28-Jun-2013 23:00:00      23:00 - 09:00
    Time information need not be stored in additional Varchar fields, if you have Date Column. You can use Date fields that store Date and time both.
    Another way of approaching this problem is with Connect By Clause or Model Clause. Use the search functionality to find solutions using those methods too. However, in my opinion, this method is the quickest of all.

  • Find Missing Folder - does not work.  Please help!

    Has anyone had this problem?  This is driving me crazy.  Any time I rename or move a folder and try to use the "Find Missing Folder" option it does not show any of my hard drives!  It has been like this through several LR updates.  I kept praying the next release of lightroom would fix this, but so far no luck.

    Did you try clicking on the left menu, on the _folder_, and selecting "Update folder location"?
    You can also try "promote parent folder" to move it up the chain and find the missing drives...
    Cheers!

  • Finding Missing Numbers

    I want to find missing numbers from a column which is alpha numeric, its last five positions are numeric. At first three positions there are different combinations of alphas i.e. *'BA ','BAW','SA ','SAA' ..........* if alphas are two then 3rd position is blank. I also need it to generalised this to cover all existing alpha numeric series.
    SELECT SUBSTR (a.claim_no, 4, 5) + 1
      FROM core_business.cb_pensioner a
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA '
       AND NOT EXISTS (
                     SELECT NULL
                       FROM core_business.cb_pensioner b
                      WHERE to_number(SUBSTR (b.claim_no, 4, 5)) =  to_number(SUBSTR (a.claim_no, 4, 5)) + 1)
       order by SUBSTR (a.claim_no, 4, 5);I am getting ORA-01722 error

    You have two issues with such a task.
    Problem 1 is how to convert the trailing part into a number so that you can compare values.
    to_number(SUBSTR (b.claim_no, 4, 5)) works, but only if the value in b.claim_no is always a number regardless of the other column criteria.
    A statement like
    WHERE SUBSTR (a.claim_no, 1, 3) = 'BA ' /* filter 1 */
    and to_number(SUBSTR (b.claim_no, 4, 5)) > 1 /* filter 2 */
    ...might fail because your table might have a value like
    b.claimno = 'XYZ1234b'
    The way you wrote the query the database will decide which filter criteria it executes first. It might be filter1, but could also be filter2. If filter2 is executed first then you will get the error message.
    Problem 2 how to order and compare different rows, so that you can find the missing values.
    Here the analytic LEAD(LAG) function is very helpful. it will give you access to the next (or previous row).
    Both problems can be overcome.
    Here is my try, but I'm not sure if it works in your case. You might need to adapt a little.
    This should work if all the rows are numeric that belong to the specific groups. if you can have wrong data in there too, then a different approach is needed.
    with testdata as (select 'XYZ1234b' claim_no from dual union all
                select 'BA 12345' claim_no from dual union all
                select 'BA 12346' claim_no from dual union all
                select 'BA 12350' claim_no from dual union all
                select 'BAW11111' claim_no from dual union all
                select 'BAW11113' claim_no from dual union all
                select 'XYZ1234b' claim_no from dual )
    /* end of test data creation */
    select claim_no, substr(claim_no, 1,3) part1, substr(claim_no, 4) part2,
           to_number(substr(claim_no, 4)) current_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4))) next_num,
           lead(to_number(substr(claim_no, 4))) over (partition by substr(claim_no, 1,3) order by to_number(substr(claim_no, 4)))
            - 1 - to_number(substr(claim_no, 4))
            as "missing_values"
    from testdata
    where substr(claim_no, 1,3) in ('BAW','BA ')
    order by claim_no;
    CLAIM_NO PAR PART2 CURRENT_NUM   NEXT_NUM missing_values
    BA 12345 BA  12345       12345      12346              0
    BA 12346 BA  12346       12346      12350              3
    BA 12350 BA  12350       12350
    BAW11111 BAW 11111       11111      11113              1
    BAW11113 BAW 11113       11113Problem 1 is solved because the where condition is always executed before the function in the select clause, especially in connection with an analytic function.
    Problem 2 is also solved by using the analytic function LEAD function. And this is fast, because you access the same table only one time. Other solution might do a subquery to fetch the value from the previous/next row. This means several accesses to the same table and is usually much slower.
    Edited by: Sven W. on Sep 20, 2010 2:32 PM

  • Vat u do when u find missing indexs as Basis guy.

    Hello Gurus,
    This question has been asked in an interview, and answer my friend gave
    1q)    vat u do when u find missing index as Basis guy.?
    A) He said he will locate the program table associated with it and let the programmer know about it,
    especially if it is a Zprogram
    to create an index on this. or if a programmer/ABAPEr creates a ticket for basis basis team will take care.
    i know for sure depending on the role  ABAER or Basis also create an index.
    2q) how do u create index
    A) thru se11
    3) y not thru oracle database
    A) SAP recommends not to touch objects at database leve (select be ok )
    After these questions my friend got doubt itseems for obvious reasons.
    Please let me know ur comments insights into this. .
    Regards
    vk

    Hi,
    Look at SAP Note 912620 - FAQ: Oracle indexes
    you get answers for your query.
    regards,
    kaushal

  • To find Missing Glyphs in text only

    Hi All,
    Requirement: I want to find missing glyphs in text only not in ART.
    What i did is, load "check glyphs only.idpp" in preflight panel and run the report. But it create report like, missing glyphs in text as well as in art also.
    Is it possible to find missing glyphs in text only not in arts?
    Please find the attachment that i created pdf with missing glyphs after that i loaded again for testing purpose.
    Thanks in advance
    BEGINNER

    Hi All Genius,
    Any Update or Idea for the above mentioned questions.
    Could anyone help me is it possible or not?
    Thanks
    BEGINNER

Maybe you are looking for

  • Using Image Processor from Bridge

    I'm trying to use the image processor from within Bridge. I have done this several times in the past, as recently as last week. I have some files selected in Bridge. I select "Tools>Photoshop>Image Processor" and the dialog box opens. Step 1 indicate

  • Strange iTunes Transfer Problem

    Hey all, first time poster. Not sure if this is the correct section for this, so I apologize in advance if it isnt. Currently running iTunes 7.5, but the problem I am having existed prior to upgrading to 7.5. I have 1200 or so songs (mp3 format) and

  • HTTP Post Error

              I am using WebLogic Server 7.0 SP1 with the iPlanet 4.1 WebLogic Plugin. When           I do a HTTP Post from my java applet using URLConnection, I am getting the following           error from the plugin:           [20/May/2003:11:19:13] f

  • Is padding required while posting to SAP

    Hi Is padding really required for a number(ex: if a field has max length is 10, can it have only 3 out of it and left others)  or string(ex: if a field has max length is 10 char, can it have only 4 out of it and left others)while posting as an IDoc t

  • Since installing Google Earth, I cannot upload any photos to any websites. How do I fix this?

    I installed Google Earth and now I am unable to upload any photos to any websites (i.e. Facebook, Ebay, etc.). I updated all plugins according to your support page and still cannot upload any photos. Please help with this matter. Thank you for your t