Find which tables are linked to this one via foreign keys

Hi, I need to drop & recreate a table, but this table is referenced by other tables via foreign key constraints.
1. Is there a query I can run to find those tables (the ones referencing this one) ?
2. What is the standard way to drop & recreate this table being referenced by others?

1) You can try the following query:
select r.owner, r.table_name
from user_constraints r, user_constraints o
where r.r_owner = o.owner and r.r_constraint_name = o.constraint_name
and o.constraint_type in ('P','U') and r.constraint_type = 'R'
and o.table_name = 'DEPT'
2) To drop tables with references you can also use drop table cascade constraints,
which will also drop constraints from tables:
[email protected]> drop table dept;
drop table dept
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by foreign keys
[email protected]> drop table dept cascade constraints;
Table dropped.
Another way is to prepare a script which will remove the tables in proper order.
Best Regards
Krystian Zieja / mob

Similar Messages

  • Way to find which tables are being accessed

    Hi Guys
    I have a large database and i want to find which tables are not being accessed (even select) from a specific period of time. is there any way to find out . I am using oracke 10g release 1
    Regards
    Khurana
    Edited by: Khurana on Sep 8, 2009 4:29 PM

    select sp.object_owner,sp.object_name,
    (select sql_text from v$sqlarea sa
    where sa.address = sp.address
    and sa.hash_value =sp.hash_value) sqltext,
    (select executions from v$sqlarea sa
    where sa.address = sp.address
    and sa.hash_value =sp.hash_value) no_of_full_scans,
    (select lpad(nvl(trim(to_char(num_rows)),' '),15,' ')||' | '||lpad(nvl(trim(to_char(blocks)),' '),15,' ')||' | '||buffer_pool
    from dba_tables where table_name = sp.object_name
    and owner = sp.object_owner) "rows|blocks|pool"
    from v$sql_plan sp
    where operation='TABLE ACCESS'
    and object_owner IN ('YOUR_USER_NAME')
    order by 1,2
    It will tell you that currently "OBJECT_NAME" is being accessed; but i think it is for full table scan.
    Source:http://www.oracle.com/technology/oramag/code/tips2005/032105.html
    Regards
    Girish Sharma

  • How to find which tables are being used by a workbook.

    I was asked by the client to generate a report which will show the Workbook name and it's corresponding tables/views.
    Any idea on how to use the EUL tables for this purpose. I know the SQL query to find the tables in case the workbook was run at least once. But I want to show the Workbook and it's table details even the report was never run.
    Advanced thanks,
    Lokesh.

    Hi Jay
    While we're on the subject of scripts, here's a couple more you might like:
    Script 1:
    =========
    This one shows you how many times an item has been used. It is useful for determining how often users make use of items in a folder. It could be used as research for a materialized view, for dropping items which are not used, or for understanding usage.
    SELECT
    OBJ.OBJ_NAME FOLDER,
    EXP.EXP_NAME ITEM,
    COUNT(QPP.QS_ID) USAGE
    FROM
    EUL5_OBJS OBJ,
    EUL5_QPP_STATS QPP,
    EUL5_EXPRESSIONS EXP
    WHERE
    OBJ.OBJ_NAME = <Folder Name>
    AND OBJ.OBJ_ID = EXP.IT_OBJ_ID
    AND INSTR(QPP.QS_OBJECT_USE_KEY,OBJ.OBJ_ID) > 0
    AND INSTR(EUL5_GET_ITEM_NAME(QPP.QS_ID),EXP.EXP_ID) > 0
    GROUP BY
    OBJ.OBJ_NAME,
    EXP.EXP_NAME;
    Script 2:
    =========
    This one examines the whole EUL and displays a count of the number of times a worksheet has been run by folder. It also shows the date and time of the last run. This one is useful to determine the most and / or least popular worksheets. Adjusting the ORDER BY clause can throw up some interesting results.
    SELECT
    OBJ.OBJ_NAME FOLDER,
    MAX(QPP.QS_CREATED_DATE) LAST_DATE,
    QPP.QS_DOC_OWNER OWNER,
    QPP.QS_DOC_NAME WORKBOOK_NAME,
    QPP.QS_DOC_DETAILS SHEET_NAME,
    COUNT(QPP.QS_ID) USAGE
    FROM
    DRAKE.EUL5_OBJS OBJ,
    DRAKE.EUL5_QPP_STATS QPP
    WHERE
    INSTR(QPP.QS_OBJECT_USE_KEY,OBJ.OBJ_ID) > 0
    GROUP BY
    OBJ.OBJ_NAME,
    QPP.QS_DOC_OWNER,
    QPP.QS_DOC_DETAILS,
    QPP.QS_DOC_NAME
    ORDER BY
    OBJ.OBJ_NAME,
    COUNT(QPP.QS_ID) DESC;
    I'm considering a blog entry of useful EUL scripts. Anyone interested? Yes - either reply here or drop me a line.
    Best wishes
    Michael

  • How to find which tables are filling by a transaction

    hi ,
            what is the process to know which talbes are filled by a particular transaction eg, by using tcode vd03 we  create customer , which we can see in kna1 tables.

    Use trace like
    - SQL trace, [ST05 (doc)|http://help.sap.com/erp2005_ehp_04/helpdata/EN/43/cb632772cd0cd4e10000000a1553f7/frameset.htm] will show you the tables accessed.
    - performance trace, [SE30 (doc)|http://help.sap.com/erp2005_ehp_04/helpdata/EN/00/e0a73e5b7a424de10000000a114084/frameset.htm] will show you the tables accessed, the FM used, etc.
    NB: VD03 is an inquiry transaction, i suppose you meant VD01
    Regards

  • How to figure out which tables are using Extensible Optimizer?

    Hi guys,
    I'm sure that there're several tables those are associated with Extensible Optimizer in my database, I can also find the Extensible Optimizer relevant type and the implementation of interface functions ODCIGetInterfaces, ODCIStatsTableFunction.
    I'm curious to know is there a way to figure out which tables are associated with this Extensible Optimizer, does anyone have any clues?
    Database: oracle 11.2
    Thank you in advance.

    Hi,
    Can you please check the below link.It may help you:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28425/ext_optimizer.htm
    Best regards,
    Rafi.
    http://rafioracledba.blogspot.com

  • I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button

    I have a document made up of separate PDF files which reside in a folder and are linked to each other via hyperlinks. Each pdf file is set to open with bookmarks displayed, however if I link from one PDF file to another and use the "Previous View" button to navigate back to my starting point the bookmarks are replaced by "page thumbnails". Is there anyway to stop this from happening?

    Hi Pusman,
    While setting up the links, if you choose to open the file in a new window then you won't face this issue, then you can simply switch to the previous file and bookmark view will remain as it is.
    Does that helps with your query?
    Regards,
    Rahul

  • How to find which datasource are using  tables AFRU ,CAUFV and AUFM

    *how to find which datasource are using  tables AFRU ,CAUFV and AUFM*

    Hi,
    You can enter your table names in SE11 transaction and click "Display" and again click "Where -Used-List". Then it will show all the places where these tables are used(Datasources)
    Hope this helps.....
    Regards,
    SUman

  • How can I find out which tables are having DDL locks?

    I can see related information by querying DBA_DDL_LOCKS view, but it doesn't give me the information which tables are having DDL locks.
    Is there a way I can find out which tables are having DDL locks?
    Thanks!

    Here's a long script written back in 2001. Still works:
    BREAK on sid on serial# on username
    COL sid        for 9999
    COL serial#    for 99999
    COL username   for a20
    COL type       for a20    trunc
    COL lmode      for a5     trunc
    COL lrequest   for a4     trunc
    COL detail     for a75    trunc
    SELECT   s.sid
           , s.serial#
           , s.username
           , DECODE(
                  l.TYPE
                -- Long locks
                , 'TM', 'dml/data enq (TM)'
                , 'TX', 'transac enq (TX) '
                , 'UL', 'pls usr lock (UL)'
                -- Short locks
                , 'BL', 'buf hash tbl (BL)'
                , 'CF', 'control file (CF)'
                , 'CI', 'cross inst f (CI)'
                , 'CU', 'cursor bind (CU) '
                , 'DF', 'data file (CF)   '
                , 'DL', 'direct load (DL) '
                , 'DM', 'mount/strtup (DM)'
                , 'DR', 'reco lock (DR)   '
                , 'DX', 'distrib tran (DX)'
                , 'FI', 'sga opn file (FI)'
                , 'FS', 'file set (FS)    '
                , 'IN', 'instance num (IN)'
                , 'IR', 'instce recvr (IR)'
                , 'IS', 'get state (IS)   '
                , 'IV', 'libcache inv (IV)'
                , 'JQ', 'job queue (JQ)   '
                , 'KK', 'log sw kick (KK) '
                , 'LS', 'log switch (LS)  '
                , 'MM', 'mount def (MM)   '
                , 'MR', 'media recvry (MR)'
                , 'PF', 'pwfile enq (PF)  '
                , 'PR', 'process strt (PR)'
                , 'RW', 'row wait (RW)    '
                , 'RT', 'redo thread (RT) '
                , 'SC', 'scn enq (SC)     '
                , 'SM', 'smon lock (SM)   '
                , 'SN', 'seqno instce (SN)'
                , 'SQ', 'seqno enq (SQ)   '
                , 'ST', 'space transc (ST)'
                , 'SV', 'seqno value (SV) '
                , 'TA', 'generic enq (TA) '
                , 'TD', 'dll enq (TD)     '
                , 'TE', 'extend seg (TE)  '
                , 'TS', 'temp segment (TS)'
                , 'TT', 'temp table (TT)  '
                , 'UN', 'user name (UN)   '
                , 'WL', 'write redo (WL)  '
                , 'TYPE = ' || l.TYPE) AS type
           , DECODE(l.lmode, 0, 'none', 1, 'null', 2, 'RS', 3, 'RX', 4, 'S', 5, 'SRX', 6, 'X', TO_CHAR(l.lmode)) A
    S lmode
           , DECODE(l.request, 0, 'none', 1, 'null', 2, 'RS', 3, 'RX', 4, 'S', 5, 'SRX', 6, 'X', TO_CHAR(l.request
    )) AS lrequest
           , DECODE(
                  l.TYPE
                , 'JQ', 'Job #' || j.job || ' (' || j.what || ') owned by: ' || j.username
                , 'MR', DECODE(s.user_type, 'BG', 'DICTIONARY OBJECT', LOWER(obj.owner) || '.' || LOWER(obj.name))
    || ' (' || LOWER(obj.TYPE) || ')'
                , 'RT', 'thread #' || LOWER(l.id1)
                , 'RW', 'file#' || LOWER(SUBSTR(l.id1, 1, 3)) || ', block#' || LOWER(SUBSTR(l.id1, 4, 5)) || ', ro
    w#' || LOWER(l.id2)
                , 'TD', 'object: ' || LOWER(obj.owner) || '.' || LOWER(obj.name) || ' (' || LOWER(obj.TYPE) || ')'
                , 'TM', 'object: ' || LOWER(obj.owner) || '.' || LOWER(obj.name) || ' (' || LOWER(obj.TYPE) || ')'
                , 'TS', DECODE(l.id2, 0, 'enqueue', 'new block allocation')
                , 'TX', DECODE(
                             lo.object_name
                           , NULL, 'rbs #' || TRUNC(l.id1 / 65536) || ', slot #' || LOWER(l.id1)
                           , 'rbs #' || TRUNC(l.id1 / 65536) || ', slot #' || LOWER(l.id1) || ', object: ' || LOWE
    R(lo.object_name))
                , 'UL', 'lock name: ' || la.name || ', expiration date: ' || TO_CHAR(la.expiration, 'DD-MON-RR HH2
    4:MI:SS')
                , 'WL', 'redo log file#' || LOWER(l.id1)
                , 'id1 = ' || l.id1 || ', id2 = ' || l.id2) AS detail
        FROM sys.v_$lock l
           , (SELECT a.sid
                   , a.serial#
                   , NVL(a.username, 'SYS (' || LOWER(b.name) || ')') AS username
                   , DECODE(a.username, NULL, 'BG', 'USER') AS user_type
                FROM sys.v_$session a
                   , sys.v_$bgprocess b
               WHERE a.paddr = b.paddr(+)) s
           , (SELECT o.obj#
                   , u.name AS owner
                   , o.name
                   , DECODE(
                          o.type#
                        , 0, 'NEXT OBJECT'
                        , 1, 'INDEX'
                        , 2, 'TABLE'
                        , 3, 'CLUSTER'
                        , 4, 'VIEW'
                        , 5, 'SYNONYM'
                        , 6, 'SEQUENCE'
                        , 7, 'PROCEDURE'
                        , 8, 'FUNCTION'
                        , 9, 'PACKAGE'
                        , 11, 'PACKAGE BODY'
                        , 12, 'TRIGGER'
                        , 13, 'TYPE'
                        , 14, 'TYPE BODY'
                        , 19, 'TABLE PARTITION'
                        , 20, 'INDEX PARTITION'
                        , 22, 'LIBRARY'
                        , 23, 'DIRECTORY'
                        , 24, 'QUEUE'
                        , 28, 'JAVA SOURCE'
                        , 29, 'JAVA CLASS'
                        , 30, 'JAVA RESOURCE'
                        , 32, 'INDEXTYPE'
                        , 33, 'OPERATOR'
                        , 34, 'TABLE SUBPARTITION'
                        , 35, 'INDEX SUBPARTITION'
                        , 39, 'LOB PARTITION'
                        , 40, 'LOB SUBPARTITION'
                        , 43, 'DIMENSION'
                        , 44, 'CONTEXT'
                        , 47, 'RESOURCE PLAN'
                        , 48, 'CONSUMER GROUP'
                        , 51, 'SUBSCRIPTION'
                        , 52, 'LOCATION'
                        , 'UNDEFINED') AS type
                FROM sys.obj$ o
                   , sys.user$ u
               WHERE o.owner# = u.user#) obj
           , (SELECT vlo.xidusn
                   , vlo.xidslot
                   , vlo.xidsqn
                   , vlo.process
                   , o.owner || '.' || o.object_name AS object_name
                FROM sys.v_$locked_object vlo
                   , sys.dba_objects o
               WHERE vlo.object_id = o.object_id) lo
           , (SELECT job
                   , schema_user AS username
                   , what
                FROM dba_jobs) j
           , sys.dbms_lock_allocated la
       WHERE l.sid = s.sid
         AND l.id1 = obj.obj#(+)
         AND l.id2 = j.job(+)
         AND TRUNC(l.id1 / 65536) = lo.xidusn(+)
         AND LOWER(l.id1) = lo.xidslot(+)
         AND l.id2 = lo.xidsqn(+)
         AND l.id1 = la.lockid(+)
         AND l.TYPE != 'MR'
    UNION ALL
                      /*** LATCH HOLDERS ***/
    SELECT   s.sid
           , s.serial#
           , s.username
           , 'latch'
           , 'X'
           , 'none'
           , h.name || ' addr=' || LOWER(RAWTOHEX(laddr)) AS object
        FROM sys.v_$process p
           , sys.v_$session s
           , sys.v_$latchholder h
       WHERE h.pid = p.pid
         AND p.addr = s.paddr
    UNION ALL
                      /*** LATCH WAITERS ***/
    SELECT   s.sid
           , s.serial#
           , s.username
           , 'latch'
           , 'none'
           , 'X'
           , name || ' latch=' || p.latchwait AS object
        FROM sys.v_$session s
           , sys.v_$process p
           , sys.v_$latch l
       WHERE latchwait IS NOT NULL
         AND p.addr = s.paddr
         AND p.latchwait = l.addr
    ORDER BY sid
           , serial#
           , username
           , 4
           , 5
           , 6
           , 7;

  • How can I know in which Tables are the fields stored

    Hi,
    In transaction FSE3 Display Financial Version
    Statement Version, if I drilldown in details, I can
    see Item No, Chart of Acc, From Accountm To Account D,
    C.
    when I do a F1 on the fields, I can see that it is a
    structure. How can I know in which Tables are the
    fields store?

    Hi Ankit,
    There are no rules or guidelines for finding the table but i will share some of the tips used generally.........but i am not sure if we can do it for a tree structure..but try anyways....
    Double click on the structure name seen on the F1 pop up window...
    in the structure screen, try to analyse the field which is very important something like a key in that set of fields or do the same for the fields which we feel are more important,then click on the domain for that field....once in the domain..click on the "where used list for the domain" on the top...
    it will display a pop up -> select only "table" and then press "Tick/OK"..A list will be displayed with the data element and table name ..from this we need to find out the right one we need either by going for text of the table or going through each and every one
    It takes time but does the job.....
    Regards
    Byju

  • In which tables are batch input error messages logged?

    does anybody know in which table are the batch input error messages logged?
    I have to display the error messages which have occured during the transaction
    I tried to find out, but i could see only the table BDCMSGCOLL, this table has only the Batch input message number and not the message itself?
    does anybody know about the batch input error messages?

    hi,
    check the sample code below.
    messtab is of type BDCMSGCOLL.
    Call the transaction and then use T100 to get the message.
    DATA: l_mstring(480).
    call transaction using
      REFRESH messtab.
      CALL TRANSACTION tcode USING bdcdata
                       MODE   ctumode
                       UPDATE cupdate
                       MESSAGES INTO messtab.
      l_subrc = sy-subrc.
      SKIP.
      LOOP AT messtab.
        SELECT SINGLE * FROM t100 WHERE sprsl = messtab-msgspra
                                  AND   arbgb = messtab-msgid
                                  AND   msgnr = messtab-msgnr.
        IF sy-subrc = 0.
          l_mstring = t100-text.
          IF l_mstring CS '&1'.
            REPLACE '&1' WITH messtab-msgv1 INTO l_mstring.
            REPLACE '&2' WITH messtab-msgv2 INTO l_mstring.
            REPLACE '&3' WITH messtab-msgv3 INTO l_mstring.
            REPLACE '&4' WITH messtab-msgv4 INTO l_mstring.
          ELSE.
            REPLACE '&' WITH messtab-msgv1 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv2 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv3 INTO l_mstring.
            REPLACE '&' WITH messtab-msgv4 INTO l_mstring.
          ENDIF.
          CONDENSE l_mstring.
          WRITE: /4 messtab-msgtyp, l_mstring(250).
        ELSE.
          WRITE: /4 messtab.
        ENDIF.
      ENDLOOP.

  • How to find which devices are still using affected domain controller

    Hi Everyone,
    We have a 5 Domain controller's in a Site. And we are going to decommisson one of our affected DC in a site.
    Can you please let me know how to find  the log files to see which devices are still using this domain controller.
    Regards,
    Neel kamal
    Neel kamal

    Neel,
    From strictly an Active Directory perspective, there is nothing special you need to do to decommission a domain controller in a site.  There are many processes that automatically balance out and recreate connections as needed without any user intervention. 
    The DC Locator process will automatically direct clients to active domain controllers, there is nothing you need to do here. 
    What you need to be concerned with are things like the following:
    DNS - Are you running AD integrated DNS and is the DC you are decommissioning hosting that roll - if so, is it the ONLY DC in the
    site that is running DNS?  You'll need at least one in the site.
    DHCP server - Is the DC you are demoting a DHCP server?  You'll need to account for that.
    Global Catalog - Is the DC you are demoting a Global Catalog server?  You'll need at least one in the site.
    File Shares - Is the DC hosting any files shares?  You'll need to move those and make sure you redirect your clients.
    Was this DC a set as a Preferred Bridgehead Server?  You'll need to undo that first.
    Those are the big ones that come to mind.  Decommissioning a DC is easy if you have prepared properly.  The others that have replied have offered some great advice which you should follow.  Do your homework and you should be fine.
    Hope that helps
    Gary
    Gary G. Gray
     MCP, MCTS, MCITP, MCT Alumni
    Please remember to mark the replies as answers if they are helpful.
    This posting is provided AS-IS with no warranties or guarantees and confers no rights.

  • How the tables are  linked to each other in ERP and CRM?

    Dear All,
    Can anyone provide the info for the below query ?
    "How the tables are  linked to each other in ERP and CRM"
    Quick response is highly appreciated.
    Best Regards
    Succhi

    Dear Buijink      ,
    Thanks for the info.
    Here in this table SMOFTABLES , it is  giving the CRM adopter objects with R/3 tables . But my requirement is  more on corresponding CRM Tables , the data fetching from R/3 tables will store in which CRM tables.To be clear the adopter objects extract the data from different R/3 tables but stores in to which tables?
    Thanks in advance
    Best Regards
    Succhi

  • Finding which table generated how much redo

    I'm wondering if we can find from any view that during this period a particular table generated how much amount of redo log , other than logminer ?
    We have a particular application and want to know which tables are generating most of the redo.

    from asktom
    see
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:477221446020
    and
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:366018048216
    Nologging only affects very very specific operations. For exmaple, from the
    alter index syntax statement in the SQL reference:
    LOGGING|NOLOGGING
    LOGGING|NOLOGGING specifies that subsequent Direct Loader (SQL*Loader) and
    direct-load INSERT operations against a nonpartitioned index, a range or hash
    index partition, or all partitions or subpartitions of a composite-partitioned
    index will be logged (LOGGING) or not logged (NOLOGGING) in the redo log file.
    In NOLOGGING mode, data is modified with minimal logging (to mark new extents
    invalid and to record dictionary changes). When applied during media recovery,
    the extent invalidation records mark a range of blocks as logically corrupt,
    because the redo data is not logged. Therefore, if you cannot afford to lose
    this index, you must take a backup after the operation in NOLOGGING mode.
    If the database is run in ARCHIVELOG mode, media recovery from a backup taken
    before an operation in LOGGING mode will re-create the index. However, media
    recovery from a backup taken before an operation in NOLOGGING mode will not
    re-create the index.
    An index segment can have logging attributes different from those of the base
    table and different from those of other index segments for the same base table.
    That also explains why the truncate above generated redo -- The statement
    "minimal logging (to mark new extents invalid and to record dictionary
    changes)." explains where that redo comes from. The blocks that were truncated
    were not logged HOWEVER the changes to the data dictionary itself were.
    .

  • Which table are notification status in?

    hi,dear experts,
    Do you know which table are notification status in? and which fields are they? I can't find them in table QMEL.
    And, which table are the system status of notification in? which fields are they?
    I are doing a report and need these information. I used ST05 to trace IW29,but i failed.
    Thank you very much.

    JEST

  • Which TABLEs are used in RWB ADAPTER ENGINE ?

    Hello everyone,
    Runtime Work Bench -> message monitoring
    we can hier select message from
    Messages of component: Integration Server  from Database 
    Which TABLEs are used to query? 
    Thx in advance
    Best Regards
    Yaning

    hello Seshagiri,
    do you know? in RWB--> Message Monitoring after selection i can get many columns.
    for example:
    End-to-End-Informationen     
    Engine          
    Status          -
    > as System Error or successful
    Start     
    Ende          
    Sender-Partner          
    Sender-Service          
    Sender-Interface     
    Empfänger-Partner     
    Empfänger-Service     
    Empfänger-Interface
    which table contains this Info. column Status ?
    Thank you
    regards
    yaning

Maybe you are looking for