重復記錄分為兩種
Mysql
create table tmp select distinct * from tableName;
drop table tableName;
create table tableName select * from tmp;
drop table tmp;
SQL Server
select distinct * into #Tmp from tableName;
drop table tableName;
select * into tableName from #Tmp;
drop table #Tmp;
Oracle
create table tmp as select distinct * from tableName;
drop table tableName;
create table tableName as select * from tmp;
drop table tmp;
發生這種重復的原因是由於表設計不周而產生的
Mysql
alter table tableName add autoID int auto_increment not null;
create table tmp select min(autoID) as autoID from tableName group by Name
create table tmp
drop table tableName;
rename table tmp
SQL Server
select identity(int
select min(autoID) as autoID into #Tmp
drop table tableName;
select * into tableName from #Tmp where autoID in(select autoID from #Tmp
drop table #Tmp;
drop table #Tmp
Oracle
DELETE FROM tableName t
說明
From:http://tw.wingwit.com/Article/program/SQL/201311/16259.html