Select table data in another table

Hello

I want to select data from A table, which is not in table B.

Currently I am doing:

Select
smofnut,
nameA,
dobA
a.
If smofnut not in
(select A snoB, B).
where smofnut = snoB
and nameA = Name)

But above all it is very slow.

I can do something like:

Select
smofnut,
nameA,
dobA
of A, B
where
EXCLUDE (smofnut = snoB and nameA = Name)

Please note that I need the place where the condition on the two columns.

any help will be appreciated.

-Harvey

What are approximate data to A and B?
What is 'very slow '?
What version of Oracle?
What is the query plan?

Without knowing anything about your system, my first thought would be to see if a NOT EXISTS happened to be faster for your data

SELECT snoA,
       nameA,
       dobA
  FROM a
 WHERE NOT EXISTS (
    SELECT 1
      FROM b
     WHERE a.snoA = b.snoB
       AND a.nameA = b.nameB )

Of course, I don't know why you want to join A & B in your NOT IN subquery. It would seem that you would need just a subquery correlated, i.e.

SELECT snoA,
       nameA,
       dobA
  FROM a
 WHERE snoA NOT IN (
    SELECT snoB
      FROM b
     WHERE a.snoA = b.snoB
       AND a.nameA = b.nameB )

This should be more efficient than the original request. The NOT EXISTS version may or may not be more effective than NOT IN according to data volumes.

Justin

Tags: Database

Similar Questions

  • Select the data in a table and update in another table

    Dear experts,

    create the table TB_ENCRYPT

    (

    Identification number,

    Varchar2 (200) KEY

    );

    INSERT INTO TB_ENCRYPT VALUES(1,'HJUVHDUIFBSDGVU');

    SELECT * FROM TB_ENCRYPT;

    1 HJUVHDUIFBSDGVU

    create TABLE users)

    username, NUMBER of

    password VARCHAR2 (200)

    );

    Insert users

    values (1, 123 # "")

    Insert users

    values (2, 456 #')

    Select * from users;

    1 123 #.

    # 2 456

    I want to select the data KEY for table TB_ENCRYPT column and update in the column of tables for the respective key user password

    TB_ENCRYPT table contains only a single key value. Comparing this key, I want to update the old value of the key to the new value.

    For encryption and decryption I followed the java class method.no is worried about that.

    create or replace

    PACKAGE PCK_ENC AUTHID CURRENT_USER AS

    FUNCTION DECRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.decrypt (java.lang.String, java.lang.String) return java.lang.String ';

    FUNCTION ENCRYPT (VARCHAR arg0, arg1 VARCHAR) AS VARCHAR BACK LANGUAGE JAVA NAME 'Encrclass.encrypt (java.lang.String, java.lang.String) return java.lang.String ';

    END;

    SELECT PCK_ENC. ENCRYPT('1234','HJUVHDUIFBSDGVU') FROM DUAL;

    HERE,

    1234 - is the password of the users table column data

    HJUVHDUIFBSDGVU - represents the key of table TB_ENCRYPT column data.

    Comparing this key, I want to update the old value of the key to the new value.

    I tried with this method

    declare

    cursor c1 is

    Select the key

    of TB_ENCRYPT

    where id = 1

    update the id;

    Start

    for c1_rec looping c1

    update users

    password is PCK_ENC. Encrypt (Password, Key)

    the location being c1;

    commit;

    end loop;

    end;

    /

    Help, please

    You can use the MERGE statement.

    merge into users
    using tb_encrypt
       on (id = userid)
      when matched then
          update set password = PCK_ENC.ENCRYPT(password,key);
    

    And why you encrypt your password. This isn't a good idea. Just password hash.

  • update of data from another table

    Hi, I would like to help. I Don t know how I can start doing:


    I have a table with a column with numbers (primary key) and I need to create another column with the same values,


    I want to change a table that has only numeric values (PK) to another
    value, so I disable the constraints of linked tables
    then I create another column that I called the "d" column and copy the values
    from column A to column D

    For example.

    TABLE XYZ

    COLUMN A: COLUMN D: (NEW)

    00001 00001
    00002-00002
    00003-00003
    00004 00004


    Can I change the values in column A and D of the column will be kept

    TABLE XYZ
    COLUMN A: COLUMN D:

    00001 99901
    99902 00002
    99903 00003
    99904-00004


    As the tables that must "point" to the column, I change the values with the new numbering

    TABLE ZZZZ

    COLUMN B: (the values of the column before the change)

    00001
    00002
    00003
    00004
    ...

    I want it like this:

    99901
    99902
    99903
    99903
    99904
    ...


    In other words, I find the current value in column D of the XYZ table for the new value that is in column a.



    I appreciate the help! :)

    Try this
    Here you will find a record in test1 for a record for each line of teste2 in teste2 joined the condition t1.numer_documento2 = t2.numero_documento.

    This is called as subquery related Co. What you were doing was under queries that and not to join the top request.

    UPDATE teste2  t2 SET NUMERO_DOCUMENTO =
    (SELECT T1.NUMERO_DOCUMENTO
      FROM teste1 t1
      WHERE t1.numer_documento2 = t2.numero_documento
      and ROWNUM = 1 )
    
    -- "Check/Select your data before you commit "
    

    SS

  • Selection of data in the table in a table

    I use apex 3.2

    I have a report where he returnts say 3 rows.


    I need to select data from a table in and table and then use the data in this table in a body of email

    or select the data in the table and use the data in the body of the sub form of e-mail

    How can I do this. ?

    something like below

    Empno name e-mail address
    1 XX [email protected]
    2 bb [email protected]
    3 [email protected] aa

    Hello

    You can take the values in the table in the cursor and use it in the part of the email.
    It will be like,

    Cursor c1 is
    Select Empno, emp email;

    In the part of the body

    Hardcode the values of the columns inside html tags

    l_body: = '

    ';

    I'm in c1
    loop
    l_body: = l_body | »

    ';
    end loop;
    l_body: = l_body | »
    EmpNo
    i.EmpNoi.Namei.email
    ';

    then use the variable 'l_body' inside your share email.

    I hope this helps.

    Kind regards
    LIBERATOR

  • How can I insert data from another table into a table containing a timestamp column

    How you insert data from another table in a table if the target table contains a timestamp column. I tried to set the default value of GETDATE() column in the target table, but it does not work.


    I use MS SQL

    Sorry, I managed to get around this by inserting null as the value

  • Redirect data to another table using before insert trigger.

    Dear all,
    How can I redirect the data to another table in a before Insert trigger? My database is Oracle10g.
    I have a table EMP (EMP_ID, LAST_NAME, SALARY).
    I have another EMP_COPY table with the same structure. I also have a before Insert trigger on the EMP table.
    Based on a condition that I have to redirect the data in table EMP_COPY. Let's say the condition is EMP_ID = 100.
    I fire an insert on EMP table for example INSERT IN EMP(EMP_ID,LAST_NAME,SALARY) VALUES(100,'Dev',500).
    On the inside of the front Insert trigger on the EMP table, I have the code
    IF EMP_ID = 100 THEN
    INSERT INTO EMP_COPY (EMP_ID, LAST_NAME, SALARY)
    VALUES(:NEW.) EMP_ID,: NEW. LAST_NAME,: NEW. SALARY);
    COMMIT;
    ON THE OTHER
    NULL;
    END IF;
    But the problem here is that data goes to EMP table of origin also although I don't want. He should do an Insert into EMP table only if EMP_ID! = 100.

    One way has been to raise a user-defined exception inside the If statement and not handle it so that the original insert on table EMP fails but INSERT comes in the EMP_COPY table. But in this solution since the inside the trigger unhandled exception, it propagates to the calling environment. And I can't stand outside relaxation as the calling environment is a form of Oracle Apps standard that cannot be customized.

    Any kind of help will be highly appreciated that I am fighting for more than two weeks.

    Thanks in advance
    Dev

    Remove the autonomous transaction pragma... and then try again.

  • I cannot select table jump extensions associated with lost data files?

    Hi ~.
    I need your help to recover my database.

    I use oracle 9.2.0.8 to Fedora 3 with mode-archive.
    and I have no backup.

    Last night, I have experienced hard drive failure.
    I tried the recovery at the level of the BONE, but I lost some data from the tablespace files.

    in any case, I wanted to recover my database without the data of lost data files.

    then, I published 'drop alter database datafile offline' and
    Start the oracle instance.

    But, data files were not eliminated from dba_data_files view and
    extensions associated with lost data files were not removed from dba_extents view!

    Query a selection table containing extensions associated with lost data files.
    I have "ORA-00376: file xxx cannot be interpreted at this time" message.

    So, my question is that...
    HOW CAN I SELECT TABLE WITHOUT EXTENSIONS RELATED TO THE LOSS OF DATA SCANNING FILES?

    Thank you.

    Hello
    Without being in archivelog and without backup, can't make any sort of recovery. This is why the backups and archivelog are so important.

    The offline data file command never actually drops the data file. It simply tells the control file now the tablespace of the said is also abandoned. It refreshes not any notice that the files are not supposed to be used or shown more than you.

    What documentation is the recovery of the database in the mode NoARch.
    http://download.Oracle.com/docs/CD/B19306_01/backup.102/b14191/osrecov.htm#i1007937

    Do you need a backup in order to recover the tables being played. Oracle is not have all the features that can currently out / skip missing extensions for you and you can read the data without them.

    HTH
    Aman...

  • Doubt to the advanced multiple selection table

    Hello

    I use a table in my page.and I have several columns of the table selection.
    I select several lines and inserts the data into another table.

    My question is when I check the multiple select box and select lines it will redirect to another page.
    and when I return to the selection page of that checkbox values are not resetting.it shows the same values.
    Please let me know how to reset these values or how these values are not checked.


    Thanks in advance
    Bharat

    Bharat,

    Attach a transitional attribute with Multiple selection... instead of any attribute associated with the table.

    Kind regards
    GYAN

  • Transformation of Scripts that run only on the selected Tables

    I'm relatively new to Data Modeler, but found almost everything to be very intuitive. I'm now doing use custom transformation scripts to dynamically add custom DDL elements. I wrote a transformation script that adds a sequence at the end of my DDL trigger successfully, and I'm happy with the results. The problem I run into is that we have two different categories of tables that require slightly different sequence triggers, but as my model is set to the level of database, my transformation scripts are applied to all arrays regardless they come what schema. Do you have any suggestions on how to limit the tables which proceeds by a transformation script? I thought to add if statements to check what schema tables are coming from, but if I have a situation where I have two different tables that require two different processing scripts, but they are in the same pattern, how can that I manage that? Ideally, I'd like to just pick a table and apply a transformation script for this table individually. Is this possible?

    I work in a relational model with Data Modeler 4.0.

    to dynamically add items customized to DDL

    you need to check the custom of DDL in DM 4.1 features - "tools > rules and design transformations > Table DDL transformations"-DM 4.1 comes with example to generate tables of the newspaper and associated trigger.

    . I wrote successfully in a transformation script that adds a sequence at the end of my DDL trigger

    Data Modeler can generate the sequence and relaxation for you - you need to define the column as 'auto increment' / identity and set in preferences, you want "trigger" put in place. 4.1 DM added support for z/OS, DB2 LUW DB2 and MS SQL Server 2012.

    Do you have any suggestions on how to limit the tables which proceeds by a transformation script? I thought to add if the instructions to check the schema, the tables are coming, but if I have a situation where I have two different tables that require two different processing scripts, but they are in the same schema

    Well you need to sort it out on yourself - you can use classification types, dynamic properties user defined properties (in DM 4.1) or put paintings in various subviews or use the search feature (4.0.3 DM / DM 4.1 comes for example how to use the search results to create subview).

    Ideally, I'd like to just pick a table and apply a transformation script for this table individually. Is this possible?

    Here is an example of how get selected tables:

    appv = model.getAppView();
    dpv = appv.getCurrentDPV();
    //check there is a diagram selected and it belongs to the same model
    if(dpv!=null && dpv.getDesignPart() == model){
     tvs = dpv.getSelectedTopViews();
     for(var i=0;i
    

    Philippe

  • Ongoing replication of the selected tables from Oracle to SQL Server

    Hi all

    How can we replicate selected tables to Oracle 11 g for SQL Server 2008/2012?

    Is GoldenGate the only option

    No matter who did it before or have the steps to do it?

    Thank you

    Define "replicate".

    If you have no budget, you can open a connection directly from SQL Server to Oracle, or vice versa. In Oracle, they are called links DB; in SQL Server, they are called "linked servers".

    Datanamic also have tools that claim to do the cross-DB replication. I have no experience with them and is not an endorsement - I know they exist.

  • 'shift' key does not work in the multiple selection table

    I created a table by dragging default datacontrol vo, the multiple value RowSelection, override the SelectionListener a manageBean method as follows:

    {} public void tableMakeCurrent (SelectionEvent selectionEvent)
    RowKeySet rks = selectionEvent.getAddedSet ();
    System.out.println (RKS. GetSize());
    Iterator it = rks.iterator ();
    {while (IT.hasNext ())}
    System.out.println (IT. Next());
    }
    }

    The problem is when I use 'shift' button help me select several lines, it will only print the last line, which I selected.

    Is there a way to fix this? Thank you...

    jdeveloper11.1.1.3

    for rowSelection multiple = to work with 'shift' you should not have the selectionListener or selectedrowkeys for your af:table
    http://www.adftips.com/2010/11/ADF-UI-implementing-multi-select-table.html
    delete selectedrowkeys and ownership selectionListener in the table and you will get select using the 'shift '.

  • Select all dates between two fields txt. How?

    In a slider form 6i, I need to select all dates between two dates provided. I have two fields text Fld1 and Chp2 with the data type date. There is no table behind the two fields.
    For example
    ': FLD1: = MARCH 1, 2013;
    ': CHP2: = MARCH 10, 2013;

    Now I have to choose all dates between 01-mar-2013 and 2013-mar-10 '. How to do?

    Gul says:
    In a slider form 6i, I need to select all dates between two dates provided. I have two fields text Fld1 and Chp2 with the data type date. There is no table behind the two fields.
    For example
    ': FLD1: = MARCH 1, 2013;
    ': CHP2: = MARCH 10, 2013;

    Now I have to choose all dates between 01-mar-2013 and 2013-mar-10 '. How to do?

    As'salamualikum Gul

    Try this

    SELECT TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum AS d
    FROM ALL_OBJECTS
    WHERE TO_DATE('01-MAR-2013', 'DD-MON-RRRR') - 1 + rownum BETWEEN TO_DATE('01-MAR-2013', 'DD-MON-RRRR') AND TO_DATE('10-MAR-2013', 'DD-MON-RRRR')
    

    Hope this helps

  • When you try to import the bookmarks, the ability to import data from another browser is not active in the import and backup from the tap in the history. So, how to import bookmarks on my file?

    I followed the instructions of Firefox to import bookmarks/favorites to Internet Explorer. It does not work because the import data from another browser is not active in the import tab and backup in the history. The instructions read to use this tab, but does not work because it cannot be selected.

    Make sure that you are not Firefox running in permanent private browsing mode.

    To view the history settings and cookies, choose: Tools > Options > privacy, choose the setting Firefox will: use the custom settings for the story of

    • Uncheck the box: [] "always use the navigation mode private.
  • (Question LVOOP) How one access the data of another class in another class?

    Hello-

    Ass title suggests, how do I access another class (or is it class?) data from another (different) class?  I will attach a picture showing where my problem is...

    I was told this:

    http://zone.NI.com/reference/en-XX/help/371361H-01/lvhowto/setting_scope_classes/

    May contain some helful info, but I can still understand how to unbundle Renault of classes inside the component class data (as seen in the attached photo).

    I think there could be something simple I'm missing here when it comes LVOOP or OBJECT-oriented programming in general... If any of you are willing to help me, it would be much appreciated!

    Thank you!

    -pat

    Personal data are always private, you can never set public. Unbundle cluster function can be used only on the thread of class when he is in the class. If you need to access private data, you must create accessors.

    It of simple, just the class right click and select new, VI for access data members. He invites you to a dialog box to fill you with what you want to create, elements of data and if you want them available through property nodes (recommended). Once completed, this will generate the Afterward screw., you can use in any other VI. The nice thing about making them nodes of property is that you can plop down a property node and it thread class, and all the created accessor functions will appear in the list.

  • How can I move photos from one date to another in my catalog? Downloaded LR of photos taken over several days to a date. LR6 PC Win7

    How can I move photos from one date to another in my catalog? Downloaded LR of photos taken over several days to a date. LR6 Win7 PC.

    Hi bubba43,

    Please select the images in the library grid mode Module and then drag and drop them in another folder you want.

    Kind regards

    Tanuj

  • Import data from another browser - only a few favorite IE9 are transferred in bookmarks. Solution HTML - HTML file all Favorites OK, but same result

    Win7 / IE9: use for the first time. Example: A folder of Favorites has 4 entries HTML - only 2 transferred. Some have none transferred - empty folder. Others have correct random + some disappeared persons.

    All of Monday
    I can see the full list of favorite IE9 HTML in HTML file on desktop with Firefox-> new tab-> open file-> open
    .
    In the desktop HTML file, there are 37 files IE9 with no more nesting 3 deep in all of a high. They are all correct wrt favorite IE9.

    All records albums + deeper nests are copied in FF ok. Random content. Copied content works ok

    7 unassigned to IE9 HTML web sites best records are also copied <-these 7 copy on FF and work well

    Example: First file in the list of IE9 has no nesting., IE9 has 4 entries - Firefox has only 2. What other method of reproduction is used.

    BTW - please let know us how I can delete entire list of bookmarks in Firefox button to try again with a clean list of bookmarks

    I'll uninstall Firefox and start over with a clean copy and use the HTML only method to try to transfer IE (files. I'll bring result.

    BTW, I'm in the United Kingdom at the time of UK - where delays to answer - need to sleep sometime!

    Tuesday night

    Hello

    I uninstalled Firefox. Re installed and loaded with favorite IE9 to HTML file.

    All seem to be copied correctly

    First time that I started using the "import data from another browser. Partial is copied.
    Then I tried 'Import HTML file' without deleting any favorite had been copied. Always partial copied.

    Everything seems fine.

Maybe you are looking for