文章詳情頁
Oracle數據庫刪除表中重復記錄的常見方法
瀏覽:92日期:2023-11-23 09:12:44
方法一:
delete from tb_channel a where a.rowid in
(select max(b.rowid) from tb_channle b
where a.policyno=b.policyno and a.classcode=b.classcode);
——這一辦法在數據記錄超過10萬時一般都會變得很慢。
方法二:
--建立臨時表,--清空原表,--插回原表,如下例:
create table temp_emp as (select distinct * from employee) ;
truncate table employee;
insert into employee select * from temp_emp;
——這一辦法適用于較大的表的情況。因為是塊操作,對應于大表效率會好很多
方法三:
--建立新表,--去重復放入,--刪除原表,如下例:
select distinct * into new_table from old_table
order by 主 鍵
drop table old_table
exec sp_rename new_table,old_table;
——這一辦法適用于較大的表的情況。因為是塊操作,對應于大表效率會好很多
排行榜
