--去重查询方法一:根据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去重等基础问题的更多相关文章

  1. oracle去重

    oracle去重 create table tmp_table3 as (SELECT seqno FROM (SELECT t.seqno,ROWID, ROW_NUMBER() OVER(PART ...

  2. 《Oracle Applications DBA 基础》- 9 - Concurrent Processing[Z]

    <Oracle Applications DBA 基础>- 9 - Concurrent Processing================================== 参考资料 ...

  3. 《Oracle Applications DBA 基础》- 9 - Concurrent Processing

    来自:http://www.itpub.net/thread-1411293-1-4.html <Oracle Applications DBA 基础>- 9 - Concurrent P ...

  4. Oracle Applications DBA 基础(一)

    1.引子 2014年9月13日 20:33 <oracle Applications DBA 基础>介绍Oracle Applications R12的系统架构, 数据库后台及应用系统的基 ...

  5. Oracle 去重查询

      Oracle 去重查询 CreateTime--2018年2月28日15:38:45 Author:Marydon (一)使用distinct --查询指定区间内表停诊字段的值 SELECT DI ...

  6. 关于Oracle的一些基础知识以及注意事项

    一.oracle基础 1.1 DDL(Data Definition Language) 数据定义语言 create drop,desc(注意,此操作只能在PL/SQL Developer的命令窗户执 ...

  7. Oracle数据库,基础知识

    1.Oracle的五大约束条件: 1 主键  primary key2 外键  foreign key,3 唯一  unique,4 检测  check5 非空  not null 实例运用: -- ...

  8. Oracle Applications DBA 基础(二)

    6.OAM及系统管理 2014年9月13日 20:40 参考资料: 1.Oracle Applications System Administrator's Guide - Configuration ...

  9. 关于Oracle数据库故障诊断基础架构

    本节包含有关Oracle数据库故障诊断基础结构的背景信息.它包含以下主题: 故障诊断基础架构概述 关于事件和问题 故障诊断基础设施组件 自动诊断信息库的结构,内容和位置 故障诊断基础架构概述 故障诊断 ...

随机推荐

  1. Office 2010 KMS激活原理和案例分享

    Office 2010 KMS激活原理和案例分享     为了减低部署盗版(可能包含恶意软件.病毒和其他安全风险)的可能性,Office 2010面向企业客户推出了新的批量激活方式:KMS和MAK.这 ...

  2. Eclipse安装python注意事项

    第一次用Eclipse来开发python,在安装环境时走了很多弯路,下面记录下正确的安装方法: 1.下载Eclipse与jdk.(注意jdk与Eclipse要么都是32位,要么都是64位) 2.安装好 ...

  3. exe文件无法打开

    1.现象 在一个XP 64位机子上从IE下载一个exe文件后,双击竟然无任何反应,以为文件有问题,但多次尝试后仍是如此,但打开cmd通过命令行启动是正常,双击该机子上其他exe文件也都能启动,但从IE ...

  4. OAuth2学习及DotNetOpenAuth部分源码研究

    OAuth2学习及DotNetOpenAuth部分源码研究 在上篇文章中我研究了OpenId及DotNetOpenAuth的相关应用,这一篇继续研究OAuth2. 一.什么是OAuth2 OAuth是 ...

  5. sturct2类型转化

    第三种struts2类型转换方式实例 1.convert.jsp <%@ page language="java" import="java.util.*" ...

  6. java 22 - 15 死锁的问题

    同步的弊端:  A:效率低  B:容易产生死锁 死锁:  两个或两个以上的线程在争夺资源的过程中,发生的一种相互等待的现象. 举例: 中国人,美国人一起吃饭. 正常情况: 中国人:筷子两支  美国人: ...

  7. windows下使用 linux命令好办法

    1. 安装下载 CygwinPortable一键安装包.7z 2. 把安装路径下/  [D:\cygwinportable\CygwinPortable\App\Cygwin\bin] 加到 Path ...

  8. Convert.ToDateTime(值),方法可以把一个值转化成DateTime类型。

    例子:将日历控件的值转化成DateTime类型. DateTime beginDate = Convert.ToDateTime(this.beginCalendar.EditValue);

  9. ext 自带搜索功能

  10. ListView实现原理

    转载:http://blog.csdn.net/guolin_blog/article/details/44996879 在Android所有常用的原生控件当中,用法最复杂的应该就是ListView了 ...