Deleting rows from a table matching values from an ascii file

Hi All,
I have an ASCII file with 12,000 lines. Each line represents a value (you may call this as bad data) that matches a database column value in table. I have to delete all the rows from a database table (~ 400,000 rows) where a column value matches the bad data value. Linux is the OS is where SQLPLUS client is installed and I can execure any SQL queries from this Linux server. Oracle DB server is 10g.
Any input on how to do this will be helpfull to me. I am not a database programmer so if any details will be appreciated.
Thanks

Hi,
That's going to be very slow (among other problems) if you don't have the bad data in a table. An index-organized table would probably be best.
Assuming the data data are uinique strings, up to 30 characters long, and that you don't need any other columns, you can create a table like this:
CREATE TABLE  bad_data
(   bad_txt    VARCHAR (30)
,  CONSTRAINT  bad_data_pk  PRIMARY KEY (bad_txt)
) ORGANIZATION INDEX;SQL*Loader is one way of getting the data from the file (doesn't have to be on the database server; it can be on your client machine) into the table.
Once you have a table, actually removing the rows from the big table might be as simple as:
DELETE  big_table
WHERE   column_a  IN
        (   SELECT  bad_txt
            FROM    bad_data
;

Similar Messages

  • Id from one table showing value from another

    I have an article id (rs_comments.id_com) but I would like it
    to take this data and collect the value from another table.
    I have joined the two tables with:
    SELECT * FROM blg_comment_com INNER JOIN blg_article ON
    idart_com=id_art
    WHERE valid_com=1
    ORDER BY date_com DESC
    rs_comments.idart_com needs to be equal to rs_comments.id_art
    displaying the value from rs_comments.title_art
    How would I go about doing this. There only seems to be an
    option in DW to do this with a dynamic list/menu but I just want to
    display the text without option to change it.
    Any help much appreciated.

    i was stupid. The answer was staring me in the face. No
    wonder no-one bothered to reply...

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Read data from ODS table using value mapping

    hi all;
    can anyone help on how to read data from ODS table using value mapping

    Mudit,
    Take a look at this blog,
    <a href="/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler">DB Lookup in Mapping</a>
    Regards,
    Bhavesh

  • What is the keyboard shortcut for "delete row" in a table?

    What is the keyboard shortcut for "delete row" in a table within a pages document?

    Click on the row number to select the entire row. Right-click, and select Delete Row from the menu. There is no keyboard shortcut.

  • How could I insert the deleted row into another table within a trigger?

    Hi,
    How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
    CREATE TRIGGER delete_trigger
    AFTER DELETE
    ON test
    FOR EACH ROW
    BEGIN
    -- How could I insert the deleted row into another table
    END delete_trigger;
    Message was edited by:
    user569548

    Hi,
    I'm not sure what's wrong there.
    I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
    ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
    SELECT column_name
    FROM all_tab_columns
    WHERE table_name = 'my_tab'; //but no rows selected?
    This topic might not be what this thread should be about. Here I posted a new thread:
    How to get colum names of the newly created table?
    Thanks.
    Message was edited by:
    user569548

  • How get all record from master and matching record from detail

    hi master
    sir i have master detail table
    i have many record in master table but some record in detail table how i get
    all record from master and matching record from detail
    such as
    select m.accid,m.title,d.dr,d.cr from master m, detail d where m.accid=d.accid
    this query not work that get only related record i need all record from master
    please give me idea
    thanking you
    aamir

    hi master
    sir i have master detail table
    i have many record in master table but some record in
    detail table how i get
    all record from master and matching record from
    detail
    such as
    select m.accid,m.title,d.dr,d.cr from master m,
    detail d where m.accid=d.accid
    this query not work that get only related record i
    need all record from master
    please give me idea
    thanking you
    aamir
    select m.accid,m.title,d.dr,d.cr
    from master m, detail d
    where m.accid=d.accid (+)The outer join operator (+) will get you all the details from master and any details from the detail if they exist, but the master details will still be got even if there are not details.
    Note: Oracle 10g now supports ANSI standard outer joins as in:
    select m.accid,m.title,d.dr,d.cr
    from master m LEFT OUTER JOIN detail d on m.accid=d.accid

  • Insert row and delete row in a table control

    Hi Experts,
    I am using a table control in module pool programming, How can I Insert row and delete row in a table control?
    Thanks in Advance....

    Santhosh,
    Iam using this code..
    FORM fcode_delete_row
                  USING    p_tc_name           TYPE dynfnam
                           p_table_name
                           p_mark_name   .
    -BEGIN OF LOCAL DATA----
      DATA l_table_name       LIKE feld-name.
    data: p_mark_name type c.
      FIELD-SYMBOLS <tc>         TYPE cxtab_control.
      FIELD-SYMBOLS <table>      TYPE STANDARD TABLE.
      FIELD-SYMBOLS <wa>.
      FIELD-SYMBOLS <mark_field>.
    -END OF LOCAL DATA----
      ASSIGN (p_tc_name) TO <tc>.
    get the table, which belongs to the tc                               *
      CONCATENATE p_table_name '[]' INTO l_table_name. "table body
      ASSIGN (l_table_name) TO <table>.                "not headerline
    delete marked lines                                                  *
      DESCRIBE TABLE <table> LINES <tc>-lines.
      LOOP AT <table> ASSIGNING <wa>.
      access to the component 'FLAG' of the table header                 *
        ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    if <MARK_FIELD> = 'X'.
        PERFORM f_save_confirmation_9101.
        IF gv_answer EQ '1'.
          DELETE <table> INDEX syst-tabix.
          IF sy-subrc = 0.
            <tc>-lines = <tc>-lines - 1.
          ENDIF.
          ELSE.
          ENDIF.
        ENDIF.
      ENDLOOP.
    in this code   ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.
    if <MARK_FIELD> = 'X'.
    this code is not working...

  • How stop PS6 from removing the DPI value from an image when using "save for the web"?

    How stop PS6 from removing the DPI-value from an image when using "save for the web"?
    Example:
    - Open a tif image, that contains a dpi value (resolution).
    - Use the splice tool in PS6.
    - Export the slices with "Save for web", as gif-files.
    Then the dpi value is removed, the gif files has no dpi value (it's empty).
    How can we stop PS6 from removing the dpi value when using "save for web"?
    OR:
    When using the slice tool, how can we save the sliced pieces without PS removing the dpi value?

    you can make your art go a little bit over the bounds. or you can make sure your artboart and art edges align to pixels

  • Delete row in database table

    Hi!
    Is there a way to delete row in database table by telling the number of the row?
    Thanx!

    Oh, sorry I didn't properly read your post.
    Try out what rvflannery suggests.
    But, for reference, you should always delete a row by it's unique ID.
    Don't go deleting things, by their position on a table, because a rows position can change.
    V

  • Reg:How to delete the column in table control also from database table.

    Hi Experts,
    Once again thank u all for giving the responses.
    one more doubt is how to delete the columns of table control and also the record shold delete from ztable.
    With Regards,
    Saroja.P.

    Hi,
    If you want to delete the rows in the table control and simultaneously delete it from the database table, then you can implement a 'DELETE' functionality specific to your table control. Have a MARK field (you will find that in the screen attributes of the table control -> give a name for the MARK field, you will find an additional MARK column at the beginning of your table control). You can check whatever rows you want to delete from the table control, call the delete module.
    "This portion of code inside the LOOP...ENDLOOP.
    IF sy-ucomm eq 'F_DELETE'.
       gt_itab2-check = mark.  " Store the MARK field status into your internal table's correspoding field 'check'
      MODIFY gt_itab INDEX tabcontrol-current_line.
    ENDIF.
    iF sy-ucomm eq 'DELETE1'.
      DELETE gt_itab WHERE check eq 'X'. "Your internal table does not have rows that you want to delete
    ENDIF.
    Now you can modify your database table using the MODIFY statement.
    MODIFY ZDB FROM TABLE gt_itab.

  • INSERT of two records into different tables (pk value from first to second)

    Hi there!
    Have probably stupid question
    Need to insert one record into table with primary key and then insert into other table record with value of primary key field from first record
    How can I do it?
    Thanks a lot!!!

    You have several possibilities. Most easiest one is listed first :)
    SQL> create table a (a number);
    Table created.
    SQL> alter table a add constraint a_pk primary key (a);
    Table altered.
    SQL> create table b (a number);
    Table created.
    SQL> alter table b add constraint  b_a_fk foreign key (a) references a(a);
    Table altered.
    SQL> insert into a values (0);
    1 row created.
    SQL> insert into b values (0);
    1 row created.Though that may not help always, so the next possibility maybe just using sequence with nextval and currval (currval can be used only in the same session and only after you have issued at least one nextval)
    SQL> create sequence a_seq;
    Sequence created.
    SQL>  insert into a values (a_seq.nextval);
    1 row created.
    SQL> insert into b values (a_seq.currval);
    1 row created.And you can use also famous returning clause. It is a bit easier to show that in the pl/sql block than pure SQL.
    SQL> declare
      2   v number;
      3  begin
      4   insert into a values (a_seq.nextval) returning a into v;
      5   insert into b values (v);
      6  end;
      7  /
    PL/SQL procedure successfully completed.And at last contents of the tables :)
    SQL> select * from b;
             A
             0
             1
             2
    SQL> select * from a;
             A
             0
             1
             2Gints Plivna
    http://www.gplivna.eu

  • How to Populate table using values from a muti-select list

    I have a muti-select list in a page, the user can select some of the values from the muti-select list. How to populate a table in a process using the selected values.
    Thanks.
    XP

    XP,
    you can also have a look at the following thread.
    Re: Shuttle Control In APEX 3
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Count rows in a table being retrieved from dba_segments

    Hello guys,
    I was wondering how can I count the rows in a table that is being retrieved from dba_segments.
    -- I am getting the table name from dba_segment
    -- Is it possible to count the number of rows in that table at the same time?
    -- If not, is there an alternative step without analyzing the table or schema, then getting the result from num_rows in all_tables?
    I want the count code to add to the select statement..
    SELECT owner, segment_name , segment_type, partition_name, bytes
    FROM   dba_segments
    WHERE  owner = UPPER( v_schema )
    ORDER BY segment_name;I try to add this to the select statement. count(segment_name), but that did not work.
    Any direction(s)?

    SYS@DEMO102> show user
    USER is "SYS"
    SYS@DEMO102> l
      1  declare
      2  counter number;
      3  begin
      4  for x in (select segment_name, owner
      5            from dba_segments
      6            where segment_type='TABLE'
      7            and owner='SCOTT') loop
      8  execute immediate 'select count(*) from '||x.owner||'.'||x.segment_name into counter;
      9  dbms_output.put_line(rpad(x.owner,30,' ')
    10                       ||'.'
    11                       ||rpad(x.segment_name,30,' ')
    12                       ||' : '
    13                       || counter
    14                       ||' row(s)');
    15  end loop;
    16* end;
    SYS@DEMO102> /
    SCOTT                         .MYTABLE14                      : 0 row(s)
    SCOTT                         .TAB3                           : 1 row(s)
    SCOTT                         .TAB4                           : 4 row(s)
    SCOTT                         .THE_TABLE                      : 5 row(s)
    SCOTT                         .C                              : 0 row(s)Nicolas.

  • How to UPDATE multiple rows in T1 with unique value from T2

    Hi,
    having on mind update query with where clause:
    WHERE (SELECT LEFT(ColumnName,7) FROM tblName) = emp2.ColumnName
    error:
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
    The statement has been terminated.
    What am I suppose to change in WHERE clause....
    Note: there is always unique value in T2 while, in T1, there could be both, only one value to be updated or number of them that all need to be updated with that unique value from T2 (alias emp2)
    T1                                            
    T2
    colimn1          column2               column3        column4
    001A001A       string1                001A001       string10
    001A001B        string2                001A005      string20
    001B005A        string3               
    001B005B        string4
    001B005C        string5      
    should become:
    T1                                           
    colimn1          column2            
    001A001A       string10               
    001A001B        string10               
    001B005A        string20               
    001B005B        string20
    001B005C        string20      
    UPDATET1
    SET column2  = emp2.column4
    FROM  T2  as emp2
        WHERE (SELECT LEFT(column1,7) FROM T1 = emp2.column3                      

    Hi daredevil3011,
    Based on my test, the error is caused by where statement in the query. Just as the error message, in your where statement, there is a subquery “SELECT LEFT(ColumnName,7) FROM tblName” follows ”=”, this is not permitted in SQL Server.
    To fix this issue, please modify your query to like below:
    UPDATE T1
    SET column2 = emp2.column4
    FROM T2 as emp2
    WHERE LEFT(column1,7) = emp2.column3
    Reference:
    WHERE (Transact-SQL)
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • Satellite A100-049 with Vista - Win DVD will not play?

    Just bought the above. All seems fine so far (but only had it 2 days) apart from when I try to play a region 2 dvd in the drive. I select WinDVD 8 and it gives the option to open from drive of folder. I select "f" being the drive and the disc spins u

  • Need help on classical report

    hi friends i need help on classical reports, sold-party, material sales and distrubitutation channel ,division, incoming orders,order number,invoice ,credit, i need sub totals and final total of invoice and each customer should display in new page .

  • [SOLVED] Pacman issue after -Syu

    Hello guys, This morning I did a full update with "pacman -Syu", before that, I also did an installation for gnome and gnome-extra as well as openoffice. There were some connection loss during the update and perhaps some packages failed to be retriev

  • Business Process_Urgent

    Hi gurus, what is business process in PA n Benefits????? plz rply bak it realy urgent... points r assured... thanx

  • Printable page's with buttons

    Hi all, In some of the custom page's we have a printable page button where user can take print out of page from PRINT option in FILE menu . Recently we have upgraded to R12 and we are facing a strange issue where when we click printable page button w