【IT168 服务器学院】删除重复记录:
办法一:
DELETE FROM TAB1 A
WHERE A.ROWID > ( SELECT MIN(B.ROWID) FROM TAB1 B WHERE A.字段=B.字段 );
其中子查询中的“WHERE A.字段=B.字段”用来写明重复条件。
——这一办法在数据记录超过10万时一般都会变得很慢。
办法二:
--建立临时表,--清空原表,--插回原表,如下例:
create table temp_emp as (select distinct * from employee) ;
truncate table employee;
insert into employee select * from temp_emp;
办法二:
--建立临时表,--清空原表,--插回原表,如下例:
create table temp_emp as (select distinct * from employee) ;
truncate table employee;
insert into employee select * from temp_emp;
——这一办法适用于较大的表的情况。因为是块操作,对应于大表效率会好很多。