create table t2 as select distinct on (col1, col2, col3, col4) * from t; drop table t; alter table t2 rename to t;