cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete duplicate records in HANA

nablan_umar
Active Contributor
0 Kudos

How to delete duplicate records using HANA SQL statement where multiple fields are grouped as keys

Accepted Solutions (0)

Answers (2)

Answers (2)

lbreddemann
Active Contributor
0 Kudos

Hmm... what happened to the good old "SEARCH FIRST"  rule that you agreed to when you accepted the ?

Deleting duplicate records is most likely one of the most common questions in every DB forum, so it's rather likely that the information you were looking for is already out there.

- Lars

former_member210482
Active Participant
0 Kudos

Hi Nablan,

1) Select the distinct records into a New Table

   CREATE COLUMN TABLE "schema"."new"

   LIKE "schema"."old";

   SELECT DISTINCT *

   FROM "schema"."old"

   INTO "schema"."new";

2) Delete the records from Old Table

   DELETE FROM "schema"."old"

3) Insert New table data back in to Old Table and drop the New table.

   INSERT INTO "schema"."old" SELECT * FROM "schema"."new";

   DROP TABLE "schema"."new";

Cheers,

Safiyu