sql - Deleting duplicate rows from sqlite database -


i have huge table - 36 million rows - in sqlite3.

in large table, there 2 columns

  • hash - text
  • d - real

however, of rows duplicates. is, both hash , d have same values.

also, if 2 hashes identical, values of d, 2 identical ds not imply 2 identical hashes

anyway, want delete duplicate rows. don't have primary key column because i'm idiot. what's fastest way this?


edit: delete dist rowid not in (select max(rowid) dist group hash);

appears trick.

you need way distinguish rows. based on comment, use special rowid column that.

to delete duplicates keeping lowest rowid per (hash,d):

delete   yourtable    rowid not in          (          select  min(rowid)             yourtable          group                  hash          ,       d          ) 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -