日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle去重等基础问题

發(fā)布時(shí)間:2025/6/17 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle去重等基础问题 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

--去重查詢方法一:根據(jù)id

select * from sxe where id in(select min(id) from sxe group by username) order by id asc;
--去重查詢方法二:根據(jù)rownum
select * from (select s.*,rownum rn from sxe s ) x where x.rn in (select min(rownum) from sxe group by username) order by id asc;
--去重查詢方法三:根據(jù)rowid
select * from (select s.*,rowid rid from sxe s) x where x.rid in (select min(rowid) from sxe group by username) order by id asc;
select s.*,rowid from sxe s where rowid in (select min(rowid) from sxe group by username) order by id asc;


--去重刪除方法一:根據(jù)ID
delete from sxe where id not in (select min(id) from sxe group by username);
--去重刪除方法二:根據(jù)rownum
--delete from (select s.*,rownum from sxe s) x where rownum not in (select min(rownum) from sxe group by username);
--去重刪除方法三:根據(jù)rowid

delete from sxe where rowid not in (select min(rowid) from sxe group by username);

?

Disctinct關(guān)鍵詞多列問題:

?

關(guān)于數(shù)據(jù)遷移,如何處理大數(shù)據(jù)量重復(fù)問題?針對Oracle

create table table1 selet * from table2; --按照table2的結(jié)構(gòu)創(chuàng)建table1,并將table2的數(shù)據(jù)導(dǎo)入table1;

create table table1 select * from table2 where 1 = 2; --按照table2的結(jié)構(gòu)創(chuàng)建table1,但不導(dǎo)入數(shù)據(jù);

開發(fā)過程中,如果涉及的數(shù)據(jù)量小的情況下刪除可以用簡單的sql執(zhí)行。但是數(shù)據(jù)量很大的遷移,百萬千萬級的數(shù)據(jù)量,性能是瓶頸的發(fā)生點(diǎn);

因?yàn)椴樵冃枰獣r(shí)間,執(zhí)行刪除需要時(shí)間,刪除完畢執(zhí)行事務(wù)需要時(shí)間,因此性能基本上為零,弄不好數(shù)據(jù)庫假死,甚至電腦假死。

所我的大數(shù)據(jù)遷移經(jīng)驗(yàn)就是:

create table temp_table select * from table2 where id not in (select min(id) from table1 group by coln) order by coln asc;

drop table table2;

rename temp_table to table2;

?

關(guān)于數(shù)據(jù)庫表結(jié)構(gòu)編輯,針對Oracle:

增加列:

alter table table1 add column_name column_type;

修改列大小:

alter table table1 modify column_name new_column_type;

修改列名稱:

alter table table1 rename column cln1 to cln2;

刪除列:

alter table tabl1 drop column cln1;

轉(zhuǎn)載于:https://www.cnblogs.com/lcngu/p/4976287.html

總結(jié)

以上是生活随笔為你收集整理的oracle去重等基础问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。