Removing duplicate rows from table in Oracle

前端 未结 22 1771
醉话见心
醉话见心 2020-11-22 12:57

I\'m testing something in Oracle and populated a table with some sample data, but in the process I accidentally loaded duplicate records, so now I can\'t create a primary ke

22条回答
  •  孤独总比滥情好
    2020-11-22 13:22

    create or replace procedure delete_duplicate_enq as
        cursor c1 is
        select *
        from enquiry;
    begin
        for z in c1 loop
            delete enquiry
            where enquiry.enquiryno = z.enquiryno
            and rowid > any
            (select rowid
            from enquiry
            where enquiry.enquiryno = z.enquiryno);
        end loop;
     end delete_duplicate_enq;
    

提交回复
热议问题