0

We have a table in our db with copied data that has completely duplicated many rows. Because the id is also duplicated there is nothing we can use to select just the duplicates. I tried using a limit to only delete 1 but redshift gave a syntax error when trying to use limit.

Any ideas how we can delete just one of two rows that have completely identical information?

Tyler
  • 3,713
  • 6
  • 37
  • 63

1 Answers1

1
  1. Use select distinct to create a new table. Then either truncate & copy the data, or drop the original table and rename the new table to the original name:
create table t2 as select distinct * from t;
truncate t;
insert into t from select * from t2;
drop table t2;
  1. Add column a column with unique values. identity(seed, step) looks interesting.
Allan Wind
  • 23,068
  • 5
  • 28
  • 38