oracle去重等基础问题
--去重查询方法一:根据id
select * from sxe where id in(select min(id) from sxe group by username) order by id asc;
--去重查询方法二:根据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;
--去重查询方法三:根据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;
--去重删除方法一:根据ID
delete from sxe where id not in (select min(id) from sxe group by username);
--去重删除方法二:根据rownum
--delete from (select s.*,rownum from sxe s) x where rownum not in (select min(rownum) from sxe group by username);
--去重删除方法三:根据rowid
delete from sxe where rowid not in (select min(rowid) from sxe group by username);
Disctinct关键词多列问题:
关于数据迁移,如何处理大数据量重复问题?针对Oracle
create table table1 selet * from table2; --按照table2的结构创建table1,并将table2的数据导入table1;
create table table1 select * from table2 where 1 = 2; --按照table2的结构创建table1,但不导入数据;
开发过程中,如果涉及的数据量小的情况下删除可以用简单的sql执行。但是数据量很大的迁移,百万千万级的数据量,性能是瓶颈的发生点;
因为查询需要时间,执行删除需要时间,删除完毕执行事务需要时间,因此性能基本上为零,弄不好数据库假死,甚至电脑假死。
所我的大数据迁移经验就是:
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;
关于数据库表结构编辑,针对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;
oracle去重等基础问题的更多相关文章
- oracle去重
oracle去重 create table tmp_table3 as (SELECT seqno FROM (SELECT t.seqno,ROWID, ROW_NUMBER() OVER(PART ...
- 《Oracle Applications DBA 基础》- 9 - Concurrent Processing[Z]
<Oracle Applications DBA 基础>- 9 - Concurrent Processing================================== 参考资料 ...
- 《Oracle Applications DBA 基础》- 9 - Concurrent Processing
来自:http://www.itpub.net/thread-1411293-1-4.html <Oracle Applications DBA 基础>- 9 - Concurrent P ...
- Oracle Applications DBA 基础(一)
1.引子 2014年9月13日 20:33 <oracle Applications DBA 基础>介绍Oracle Applications R12的系统架构, 数据库后台及应用系统的基 ...
- Oracle 去重查询
Oracle 去重查询 CreateTime--2018年2月28日15:38:45 Author:Marydon (一)使用distinct --查询指定区间内表停诊字段的值 SELECT DI ...
- 关于Oracle的一些基础知识以及注意事项
一.oracle基础 1.1 DDL(Data Definition Language) 数据定义语言 create drop,desc(注意,此操作只能在PL/SQL Developer的命令窗户执 ...
- Oracle数据库,基础知识
1.Oracle的五大约束条件: 1 主键 primary key2 外键 foreign key,3 唯一 unique,4 检测 check5 非空 not null 实例运用: -- ...
- Oracle Applications DBA 基础(二)
6.OAM及系统管理 2014年9月13日 20:40 参考资料: 1.Oracle Applications System Administrator's Guide - Configuration ...
- 关于Oracle数据库故障诊断基础架构
本节包含有关Oracle数据库故障诊断基础结构的背景信息.它包含以下主题: 故障诊断基础架构概述 关于事件和问题 故障诊断基础设施组件 自动诊断信息库的结构,内容和位置 故障诊断基础架构概述 故障诊断 ...
随机推荐
- 了解 Office 365
Office 2016刚刚发布,那么Office 2016和Office 365是什么关系呢?通过Office 365与传统Office套件的对比,我们可以更好地理解SaaS的本质.SaaS的商业模式 ...
- HttpURLConnection用法详解
针对JDK中的URLConnection连接Servlet的问题,网上有虽然有所涉及,但是只是说明了某一个或几个问题,是以FAQ的方式来解决的,而且比较零散,现在对这个类的使用就本人在项目中的使用经验 ...
- Codeforces 486E LIS of Sequence --树状数组求LIS
题意: 一个序列可能有多个最长子序列,现在问每个元素是以下三个种类的哪一类: 1.不属于任何一个最长子序列 2.属于其中某些但不是全部最长子序列 3.属于全部最长子序列 解法: 我们先求出dp1[i] ...
- MipMap
MipMap 首先从MIPMAP的原理说起,它是把一张贴图按照2的倍数进行缩小.直到1X1.把缩小的图都存储起来.在渲染时,根据一个像素离眼睛为之的距离,来判断从一个合适的图层中取出texel颜色赋值 ...
- 在移动端如何选择字体大小和布局的单位,px或dp?
android开发中,文字大小的单位是sp,非文字的尺寸单位用dp,但是我们在设计稿用的单位是px.这些单位如何换算,是设计师.开发者需要了解的关键. 简单理解的话,px(像素)是我们UI设计师在PS ...
- Python的高级特性2:列表推导式,生成器与迭代器
一.列表推导式 1.列表推导式是颇具python风格的一种写法.这种写法除了高效,也更简短. In [23]: {i:el for i,el in enumerate(["one" ...
- SpringMVC的Controller中使用线程安全的初始化
因为SpringMVC的Controller默认是单例, 在这种情况下, Controller中使用的私有变量必须也是单例, 例如各种service, 否则会有多线程访问数据互相修改的问题. 对于需要 ...
- 10 Things Every Java Programmer Should Know about String
String in Java is very special class and most frequently used class as well. There are lot many thin ...
- react拷贝index.html很恶心之解决办法
https://www.npmjs.com/package/html-webpack-plugin
- usb驱动开发21之驱动生命线
现在开始就沿着usb_generic_driver的生命线继续往下走.设备的生命线你可以为是从你的usb设备连接到hub的某个端口时开始,而驱动的生命线就必须得回溯到usb子系统的初始化函数usb_i ...