成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

Oracle數(shù)據(jù)庫(kù)刪除表中重復(fù)記錄的常見方法

瀏覽:120日期: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);

——這一辦法在數(shù)據(jù)記錄超過10萬時(shí)一般都會(huì)變得很慢。

方法二:

--建立臨時(shí)表,--清空原表,--插回原表,如下例:

create table temp_emp as (select distinct * from employee) ;

truncate table employee;

insert into employee select * from temp_emp;

——這一辦法適用于較大的表的情況。因?yàn)槭菈K操作,對(duì)應(yīng)于大表效率會(huì)好很多

方法三:

--建立新表,--去重復(fù)放入,--刪除原表,如下例:

select distinct * into new_table from old_table

order by 主 鍵

drop table old_table

exec sp_rename new_table,old_table;

——這一辦法適用于較大的表的情況。因?yàn)槭菈K操作,對(duì)應(yīng)于大表效率會(huì)好很多