id爲sequence
create table table_tmp
as (select distinct aa,bb,cc,dd from table);-----創建臨時表,並保存不重複的數據
truncate stompcomment cascade----清空原表數據,並清空通過外鍵約束引用被清空的表的表
或者,delete from stompcomment;-----清空原表數據
兩者不同是前者可以立即回收表的存儲空間
insert into table select nextval('table_sequence'::regclass) as seq,* from table_tmp----將臨時表的數據寫回到原表中
drop table table_tmp;--------刪除臨時表