×

Loading...

Topic

This topic has been archived. It cannot be replied.
  • 工作学习 / IT技术讨论 / DATABASE: In one table, no primary key, there are two exactly same records. How to delete one of them? tks.
    • You can use ROWID to identify two records with same contents, then write a PL/SQL as inside:
      ... ...
      cursor cur_del is sel * from tab1;
      ... ...
      begin
      for cur_1 in cur_del loop
      delete from table1
      where column1=cur_1.column1
      and column2=cur_1.column2
      ... ...
      and columnn=cur_1.columnn
      and rowid<>cur_1.rowid;
      commit;
      end loop;
      end;
    • Acturally it \
    • a sql statement
      using \
      • both ";" and "/" are correct :))
        • Thank you!
    • delete from table_name where condition_clause and rowid = 1
      • rowid should be rownum
    • delete from table_name where rowid=(select min(rowid) from table_name where condition_clause);
      • yes, It is a good idea. it is the simplest solution.
        you must be verse in SQL. Most people dont take care of it. It is wrong.