Oracle - deleting duplicates

后端 未结 2 1280
暗喜
暗喜 2021-01-28 10:55

I have found the following way for removing duplicates:

DELETE FROM
   table_name A
WHERE
  a.rowid >
   ANY (
     SELECT
        B.rowid
     FROM
        t         


        
2条回答
  •  粉色の甜心
    2021-01-28 11:33

    Like this:

    DELETE FROM         // The command to delete
       table_name A     //the table in which you want to remove duplicate
    WHERE               //condition
      a.rowid >         //checking the rowid which oracle adds to each row. Oracle Database rowid values contain information necessary to locate a row.
       ANY (             //any row which has a condition
         SELECT          //select
            B.rowid      //rowid
         FROM             //from  
            table_name B    //table name with alias name as B. Is used for making a self join
         WHERE               //condition
            A.col1 = B.col1    //where the column1 has the same rowid 
         AND                    //and
            A.col2 = B.col2     //where the column2 has the same rowid 
            ); 
    

提交回复
热议问题