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.
-howru(How are you?);
2001-9-30(#213661@0)
You can use ROWID to identify two records with same contents, then write a PL/SQL as inside:
-wander2001(wander);
2001-9-30{287}(#213717@0)
... ...
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 \
-stride(stride);
2001-9-30(#213720@0)
a sql statement
-stride(stride);
2001-9-30{8}(#213722@0)
using \
both ";" and "/" are correct :))
-wander2001(wander);
2001-9-30(#213753@0)
Thank you!
-howru(How are you?);
2001-9-30(#213767@0)
delete from table_name where condition_clause and rowid = 1
-fromztoa(fromZtoA);
2001-9-30(#213810@0)
rowid should be rownum
-fromztoa(fromZtoA);
2001-9-30(#213812@0)
delete from table_name where rowid=(select min(rowid) from table_name where condition_clause);
-onewayticket(onewayticket);
2001-10-2(#215021@0)
yes, It is a good idea. it is the simplest solution.
-sameway(sameway);
2001-10-3{72}(#215387@0)
you must be verse in SQL. Most people dont take care of it. It is wrong.