Search code examples
databaseorientdbnosql

How to delete duplicate records in a table using Orientdb


Select * from table
cola colb
a     b
a     c
a     b
a     b

How to delete duplicate records excluding the first entry in a table.Expected result :

 Select * from table
cola colb
a     b
a     c

Solution

  • As a workaround, you can try the following solution:
    1. Create new (temporary) class

    create class table_temp
    
    1. Insert grouped (distinct) values to new class table

      insert into table_temp from select cola, colb from your_table group by cola, colb

    2. Clean your table delete from your_table

    3. Insert data from new table
      insert into your_table from select cola, colb from table_temp group by cola, colb

    Ideally, these steps should be done within single transaction.