Discussion:
how to delete the duplicate row in a table ?
(too old to reply)
S***@infosys.com
2007-10-05 04:18:36 UTC
Permalink
Hi,

how to delete the duplicate row in a table ? ie 2 same identical rows
i cant delete using a where clause because it deletes both the rows.

please reply for this as soon as possible

thank u.
Mark A
2007-10-05 04:30:20 UTC
Permalink
Post by S***@infosys.com
Hi,
how to delete the duplicate row in a table ? ie 2 same identical rows
i cant delete using a where clause because it deletes both the rows.
please reply for this as soon as possible
thank u.
1. Use a cursor, and "delete where current of cursor" if a duplicate row
exists. This is probably easiest to implement in an SQL stored procedure
because java heads don't understand cursor processing any more.

2. Export the data using a distinct select statement, and then load or
import the exported data with the replace option.
S***@infosys.com
2007-10-05 04:44:12 UTC
Permalink
Can we delete a duplicate row use a distinct clause???

Is there anything like that to delete ?
m***@mail.ru
2007-10-08 07:37:06 UTC
Permalink
Post by S***@infosys.com
Hi,
how to delete the duplicate row in a table ? ie 2
e 2 same identical rows
i cant delete using a where clause because it
it deletes both the rows.
please reply for this as soon as possible
thank u.
Hi.
If you are at v8.1.4 or later:
--
delete from
(
select rownumber() over() rn
from <your_table>
where <condition_on_your_2_identical_rows>
) t
where rn=1
--

Sincerely,
Mark B.

Continue reading on narkive:
Loading...