delete records that are related to another table

I want to delete records from a table (A), these recordings has a relationship with another table (B)

using a query to set these records is that I want to delete

with B as
(
f select '2', '3' l double
Union of all the
f select '2', '3' l double
Union of all the
f select '4', '4' l double
)


Select * from A, B
where B.f() > 3 and b. > 3
and A.f. = B.f()
and A.l = b.

Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production


Thanks in advance!

Hello

Here's one way:

DELETE     a
WHERE     f     > 3
AND     l     > 3
AND     (f, l)     IN (
               SELECT  f, l
               FROM     b
                 )
;

Tags: Database

Similar Questions

  • best way to get documents that are NOT in another table

    I have two large tables in oracle. An array of account that has millions of rows. Each account can be registered in a particular program and can therefore also to the Enrollment table, also with millions of rows. I am to find the most optimal way to find all accounts into ACCOUNT which are NOT in the Enrollment table.

    I did something like this:

    Select / * + index (ACCOUNT idx_acct_no) * /.
    a.Acct_No
    one account
    If a.acct_no not in (Select e.acct_no from e REGISTRATION);


    It takes a long time to run, even though I'm using the index.

    I even tried to use the PK on the ACCOUNT dashboard, as is a FK on the ENROLLMENT table as such:

    Select a.acct_no
    one account
    Where a.id not in (Select e.id of e REGISTRATION);

    too, it takes too much time to recover (if any).

    Is there a better way to make this choice please?

    +
    Try this:

    SELECT a.acct_no
      FROM ACCOUNT a
     WHERE NOT EXISTS (SELECT '?'
                         FROM ENROLLMENT e
                        WHERE e.acct_no = a.acct_no);
    

    : p

  • Before file is deleted, the record must be insert into another table

    Hi friends,

    I have to create tabular form to delete some record. Using this tabular form I deleted successfully.
    But I want to when I delete a record before deleting record that he should go to another table.



    How can I do that.




    Ed

    Hello

    You create before you remove the trigger table.
    http://download.Oracle.com/docs/CD/B10500_01/server.920/a96524/c18trigs.htm

    BR, Jari

  • Selection of records that are greater than the current week or

    Hi I have a table with the table structure

    CREATE TABLE OMPPRODUCTION
    (
    LOCATIONID VARCHAR2 (200 BYTE) NOT NULL,
    IPC VARCHAR2 (200 BYTE) NOT NULL,
    PRODUCTIONWEEK VARCHAR2 (200 BYTE) NOT NULL,
    QUANTITY VARCHAR2 (2000 BYTE),
    PRODUCTIONCODE VARCHAR2 (2000 BYTE),
    MOULDQUANTITY VARCHAR2 (2000 BYTE),
    VARCHAR2 (2000 BYTE) SOURCE,
    VARCHAR2 (2000 BYTE) APPLICATION,
    COMMENTS VARCHAR2 (2000 BYTE),
    DATE OF TLM,
    ADSTAT CHAR (1 BYTE),
    SID NUMBER (10, 0),
    SECURITYLEVEL VARCHAR2 (100 BYTE),
    ENABLE CONSTRAINT PRIMARY KEY (LOCATIONID, CPI, PRODUCTIONWEEK) OMPPRODUCTION_PK
    )

    He has field PRODUCTIONWEEK that is to be given YYYYMMDD.

    I want to select records that are starting the week underway (Monday as departure day).

    for example, the date is 20120210 so I would choose the lines including the date more or equal to 20120206.

    Can someone guide me how it is possible?

    Published by: MaheshGx on 6 February 2012 16:16

    MaheshGx wrote:
    Select * from OMPPRODUCTION where to_number (to_char (to_date (productionweek, 'yyyymmdd'), 'WW')) > = to_number (to_char (sysdate, "WW"))

    Wow, why so complicated?

    You work with dates, so:

    (a) why the hell you store dates in a column VARCHAR2? (and worse yet, why is 200 bytes of length)? Store dates as the DATE. The optimizer based on CSSTidy will thank you. As well, you know, you won't be wasting space.
    (b) compare with the dates, not dates-converted dates - dates-converted-to-number numbers. Why do extra work when you have not to?

    Since you're after weeks from Monday, I'd go for the format mask "IW", since it is fixed and will always return the Monday of the current week ("WW" could return Sunday or Monday, depending on what are your NLS settings.) I'd rather have my labour code for those who executes it, regardless of their NLS settings).

    So, given the fact that your column is not the DATE data type, it would be more effective for you;

    select *
    from   ompproduction
    where  trunc(to_date(productionweek,'yyyymmdd'), 'iw') >= trunc(sysdate, 'iw');
    

    If you have an index on productionweek that you need help in this query, then I suggest to convert it to a basic index function.

  • My iPhone does not to import! How can I appear in the Photos and delete those that are already imported?

    My iPhone does not to import! How can I appear in the Photos and delete those that are already imported?

    My iPad appears fine with an option to import the 'new' photos and then delete them once they are imported. However my iPhone appears not at all on the pictures. Although most is already imported via the cloud, some are not, but more importantly, I would remove at least half of 30 000 photos that are taking place on my phone and a "clear items after button import" would be nice right now! I tried to turn off photo stream on my phone, but it still does not appear in the application.

    What can I do?

    Thank you!

    If you use iCloud photo library you cannot delete pictures after the import (or) - deletions on any device will be on all devices - if storage is a question about a device set to use optimized photos

    LN

  • The columns appear in the data store that are not in the table

    Hi guru,.

    I have a table that I built in Oracle and added to ODI by refactoring it, but when I add it as a source to my interface, it contains columns that are not physically in the Oracle table that I can look into a TOAD. I dropped the prior of the table deleted-> interface-> reverse engineering table but I get an additional column. Y at - it an explanation for that? I have the table listed in a stored procedure - should I delete this step as well before reverse engineering, or is something else.

    Thanks in advance.

    Mike

    Yes. There is a possible explanation. How do you are engineering it? If you use Oracle RKM, you may be using a customized version of this KM which adds a column of your table name...

  • I noticed that many of my updates there is 2 times. The same exact. Can I safely delete those that are lined and exactly the same thing? Seems I don't need the same exact 2 and 3 updates times.__Thanks__Michael

    I noticed that many of my updates of widows is 2 times. The exact same ones. I can safly remove those that are lined and exactly the same thing? Seems like I don't need at the same time exact windows updates 2 and 3.
    Here's what are installed now that confuses me.
    Running vista Home premium
    version 6.0.6002 Service Pack 2 Build 6002
    PC x 64
    Intel Core 2 Duo CPU T5550 1.83 GHz, 1833 MHz, 2 Lossnay, 2 Log
    4.00 GB
    Microsoft Silverlight
    These files were add and remove.
    Update for Microsoft Visual C++ 2005 ALT kb973923 - x 6...
    Update for Microsoft Visual C++ 2005 ALT kb973923 - x 8...
    Microsoft Visual C++ 2005 Redistributable
    Microsoft Visual C++ 2005 Redistributable
    Update for Microsoft Visual C++ 2005 ALT kb973924 - x 8...
    Microsoft Visual C++ 2005 Redistributable - x 86 9.0.2...
    Microsoft Visual C++ Run Time Setup Lib
    Would it not be better to uninstall all these and start from scratch with Silverlight?
    Or!
    To uninstall only some?
    Very confused about this.
    Some tips would help a lot.
    I think I posted all the files that were related to this as well as information on the system.
    Thank you
    Member of 1care Michael B.

    Mike

    CF. http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/b9132e0a-31ad-4f3c-af7d-8719972453ab

    Visit the Microsoft Solution Center and antivirus security for resources and tools to keep your PC safe and healthy. If you have problems with the installation of the update itself, visit the Microsoft Update Support for resources and tools to keep your PC updated with the latest updates.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • How to delete contacts that are not in my contact list.

    I have contracts that are not in my contacts list, but when I press on to and simply start typing the email arrives and I really need to get off my hotmail which are the most to my list of contacts of people I need to unlocked then remove them. Please help I tried the arrows and highlighting but nothing not working

    Please ask in the appropriate forum.

    Windows Live Mail Forum
    http://windowslivehelp.com/forums.aspx?ProductID=15

  • BlackBerry Smartphones how delete songs that are not registered in my media card/device

    In part... "Serious problem", but I have 10 songs that are not registered on my media card or device and will not play... I tried wiping/formatting of my phone, but they will not disappear.

    Hello! What happens when you try to play these songs?

    Try going to your support and click options > Explorer > device then look for songs, try to remove the it.

    Keep us informed
    ________________________
    Click 'Like' If you want to thank someone. If the problem is resolved to accept it as a 'Solution', so that others can use it.

  • Smartphones blackBerry calendar deletes appointments that are older than two months.

    Hello.  I'm sorry if this has been posted elsewhere, but I search and did not find an answer.  My calendar on Blackberry and Outlook is the erasure of the appointments that are older than two months.  Appointments to the breast to aim for two months and the future demand are very good.  Is there a setting that I can change in the Blackberry or Outlook calendar to avoid this problem or is it a problem of memory?  Thanks in advance.

    On your BB > opens the calendar > Menu > Options > General Options (if there is a general options, some versions go directly to the screen > scroll down to 'Keep the appointments' and the value you want length.)

  • If I build a Web site in Dreamworks can I use my google domain name that is related to another site of my galleries hosting?

    If I build a Web site using Dreamworks can I use my Google domain name that is related to my site of galleries?

    !@

    A domain name can refer to a single server and ip address, so if the Dreamweaver site must be in the same site as the Gallery, they can share the domain name.

  • I need my email to other identifiers that are related to my Hot Mail windows live ID__

    WHAT ARE ALL MY E-MAIL RELATED IDs WITH HOT MAIL address?

    Hi Tinav,

    The question you have posted is related to Hotmail and would be better suited to the community of Windows live.

    Please visit the link below to find a community that will support what ask you:
    http://windowslivehelp.com/community/

    Halima S - Microsoft technical support.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • Public records that are not visible in Windows Explorer

    A couple of days, when I tried an attachment to an e-mail, Public Documents didn t appear. Normally it is under Documents, next to My Documents. But now the Documents contains: My Documents and Documents (C :). And that the Documents (c) contains a folder named MAGIX_Video_deluxe_16, (paying) video editing software. This folder contains subfolders with nothing in it. In any case, I just moved because this isn't a big deal, as I find the search bar hollow. Later this program is not only happened with Hotmail, but also with Microsoft Office.

    But now he also started to happen when I open Windows Explorer. It's huge because no irritation only me, but my family also uses public records files a lot. Can someone help me?
    Edit: If I access public Documents hollow C:\Users\Public\Public Documents, the files are there. It's that when I access the files with Windows Explorer.

    Try this first,

    Then, open the site link,

    If the Public location does not appear browse it and click Add.

    Remove anything but my Documents in the example in the photo,

    Repeat for the other categories.

  • Duplicate records and modify data in another table

    First of all, I have two tables (CUSTOMER and ADDRESS) with the following definition:

    CUSTOMER has 7 columns (aa, ab, ac, ad, ae, af, ag)

    AA is the primary key

    AE, af, ag are the duplicate columns and he should be arrested by ae, af, ag

    a foreign key between the CUSTOMER and ADDRESS

    ADDRESS has 5 columns (bb, bc, bd, aa)

    BB is the primary key

    Here is an example of the content at the start

    CUSTOMER

    AA ab ac ad ae af ag

    12 432 23 44 32 22 44

    13 32 33 213 32 22 44

    14 321 22 22 17 21 33

    15 22 43 90 17 21 33

    16 21 23 94 17 21 33

    ADDRESS

    BB bc bd be aa

    17 321 33 23 12

    18 123 32 22 13

    20 22 23 34 14

    21 22 21 22 15

    22 12 34 22 16

    And the result,

    CUSTOMER

    AA ab ac ad ae af ag

    12 432 23 44 32 22 44

    14 321 22 22 17 21 33

    ADDRESS

    BB bc bd be aa

    17 321 33 23 12

    18 123 32 22 12

    20 22 23 34 14

    21 22 21 22 14

    22 12 34 22 14

    How could I do with SQL?

    Hello

    user10681153 wrote:

    ...
    INSERT INTO CUSTOMERS VALUES (12,432,23,44,32,22,44);

    INSERT INTO CUSTOMERS VALUES (13,32,33,213,32,22,44);

    INSERT INTO CUSTOMERS VALUES (14,321,22,22,17,21,33);

    INSERT INTO CUSTOMERS VALUES (15,22,43,90,17,21,33);

    INSERT INTO CUSTOMERS VALUES (16,21,23,94,17,21,33);

    INSERT INTO THE ADDRESS VALUES (17,321,33,23,12);

    INSERT INTO THE ADDRESS VALUES (20,22,23,34,14);

    INSERT INTO THE ADDRESS VALUES (21,22,21,22,15);

    INSERT INTO THE ADDRESS VALUES (22,12,34,22,16);

    In your original message, there are 5 rows in address; now, there are only 4.  In light of these new data, I guess that the results you origianlly displayed for the customer are always the same, but the results that you want to start address are now:

    BB BC BD BE AA

    ---------- ---------- ---------- ---------- ----------

    17 321 33 23 12

    20 22 23 34 14

    21 22 21 22 14

    22 12 34 22 14

    I don't see anything wrong with my previous solution.  Do you have?

  • Records that are common between user

    I have 3 users in the schema.
    User1
    UserB
    UserC
    PURCHASE table name exists in all three data diagram above
    As
    UserA-> purchase - id_no, active_flag
    UserB-> purchase - id_no, active_flag
    UserC-> purchase - id_no (note there is no active_flag in this scheme.


    I want to choose the user who has the same id_no by on all three.
    I need to display ID_no, active_flag (weather it of active or not) and include the Source of recordings (name of user/schema)



    1.I began with two tables...
    2. I need to include the table shape UserC as well, please, not userc.purchase is not active_flag

    Help, please...
     
    select registration_number, flag_passive, cnt1 , cnt2 ,CASE WHEN CNT2 >0 THEN  ('USERA -  USERB')  END Source from (
       select id_no , active_flag, 
       sum(case when src=1 then 1 else 0 end) cnt1, 
       sum(case when src=2 then 1 else 0 end) cnt2 
       --sum(case when src=3 then 1 else 0 end) cnt2 
    from 
       ( 
       select id_no , active_flag, 1 src from usera.purchase  
       union all
       select, id_no , active_flag 2 src from  userb.purchase 
       --union all
       --select id_no , ? from  userc.purchase  
       ) 
    group by id_no , active_flag
    ) 
    where cnt1 = cnt2;
     
    CREATE TABLE purchase
    (
      ID_no            NUMBER(12)  , 
      ACTIVE_FLAG_PASSIVE          VARCHAR2(1 CHAR) DEFAULT 0
    )
     
    Insert into purchase   ( ID_NO, ACTIVE_FLAG ) Values   (1119 , 0);
    Insert into purchase   ( ID_NO, ACTIVE_FLAG ) Values   (1120 , 0);
    Insert into purchase   ( ID_NO, ACTIVE_FLAG ) Values   (1119 , 1);
    Insert into purchase   ( ID_NO, ACTIVE_FLAG ) Values   (1131 , 1);
    Insert into purchase   ( ID_NO, ACTIVE_FLAG ) Values   (1145,  0);
    Insert into purchase   ( ID_NO, ACTIVE_FLAG )  Values   (1146, 0);
    COMMIT;
    Published by: Smidreb on May 18, 2012 08:57

    Hello

    Maybe that's what you want:

    WITH     combined_data     AS
    (
       SELECT  id_no,        active_flag, 1  AS src     FROM usera.purchase
           UNION ALL
       SELECT  id_no,        active_flag, 2 AS src     FROM userb.purchase
           UNION ALL
       SELECT id_no, NULL AS active_flag, 3 AS src  FROM userc.purchase
    )
    ,     got_src_cnt          AS
    (
         SELECT  c.*
         ,      COUNT (DISTINCT src) OVER (PARTITION BY  id_no)
                        AS src_cnt
         FROM    combined_data  c
    )
    SELECT     id_no, active_flag, src
    FROM     got_src_cnt
    WHERE     src_cnt     = 3
    ;
    

    Please post instructions and CREATE TABLE INSERT for examples of data, but you have posted only a single table. Isn't the whole point of this problem by comparing 3 different tables, which are not the same? Thanks for posting all the tables involved, and the results you want from this data.
    For testing purposes, poretend all tbles are in the same pattern, with names like usera_purchase. It will be commonplace to chnge the '_' for a '.' later.
    Always tell what version of Oracle you are using.

Maybe you are looking for