------解决方案-------------------- 假设ID唯一 在NAME、ID上建立 索引 select * from tt a where not exists(select 1 from tt where a.name=name and a.id>id)
------解决方案-------------------- 临时表的效率应该是比较高的。create table x as select id,name from yourTable group by name
虽然你可以
delete from yourTable a where exists (select 1 from yourTable where id>a.id and name=a.name)
------解决方案-------------------- 建立一张新表,将旧表数据导入新表(通过sql完成)
Insert into Table2(name,id) select distinct name,id from Table1
或者通过 SELECT INTO FROM语句 语句!
------解决方案--------------------
SQL code
DELETE FROM 表A a
WHERE EXISTS(SELECT 1 FROM 表A WHERE id>a.id and a.name=name);
------解决方案-------------------- 就用临时表好了
------解决方案-------------------- 临时表的效率是比现在的查询效率要高的多。
------解决方案--------------------