postgresql delete duplicated rows

626 ワード

Deleting duplicates
Windows function row_numberを使用したデータpartition例:
isnp=# create table student (id serial, name text, age int);
isnp=# \d student;
isnp=# with cte as (select *, round(random()*100) as d from generate_series(1,10000) as r) insert into student (name, age)  select 'lmy'||r, d from cte;
### genetate duplicate row
isnp=# insert into student (name, age) select name, age from student where 100 1);