--去重查询方法一:根据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. C++11 之 delete 和 default

    1  特殊成员函数 设计一个类,没有成员函数 (member function),只有数据成员 (member data) class DataOnly { private: std::string ...

  2. Color国际青年公寓

    Color国际青年公寓介绍.md-/Users/zjh/Documents html{font-family: sans-serif;-ms-text-size-adjust: 100%;-webki ...

  3. 单调队列优化DP,多重背包

    单调队列优化DP:http://www.cnblogs.com/ka200812/archive/2012/07/11/2585950.html 单调队列优化多重背包:http://blog.csdn ...

  4. Java虚拟机详解----JVM常见问题总结

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

  5. Jenkins学习二:Jenkins安装与配置

    安装前关注: Q:应该选择哪个版本的Jenkins? A:如果你是公司正式使用推荐长期支持版(LTS),原因:稳定.如果你是学习,随便哪个版本都可以. Q:JDK应该安装哪个版本的? A:推荐安装JD ...

  6. Eclipse c++代码提示,覆盖下面代码的问题。

    今天在使用Eclipse自动提示时,会覆盖下面行的代码!!! 这个错误几乎不能忍,goolge无果. 手动尝试去掉,全部代码提示,终于找到解法办法,但是原因未知. 如下图:需要去掉 "Par ...

  7. 一句话爆破速度提升一千倍python脚本

    这个脚本是接地提供的思路,一句话爆破速度提升一千倍,看了他的帖子然而没有看到工具,思路很牛逼,我提供一个Python脚本本地测试了下,十万密码只需要3秒,速度还是可以的 # coding:utf-8 ...

  8. Openjudge 1.13-40 提取数字串按数值排序

    40:提取数字串按数值排序 查看 总时间限制:  1000ms 内存限制:  65536kB 描述 给定一个字符串,请将其中的所有数字串提取,并将每个数字串作为整数看待(假设可以用int 表示),按从 ...

  9. git工作区、暂存区、版本库之间的关系

    区分三者关系 Git最让你迷惑的无非是它里面的各种概念了,如果是刚开始接触Git希望看完本篇介绍之后有一个清晰的认识,笔者认识也有限这里只说说个人对使用Git的感受,说一下它里面的几个最常用的概念的理 ...

  10. [py]文件 字符串 列表特例

    文件 readlines 列表 readline 字符串 read 字符串   列表---拆分---小列表   f=file('test.log','r') for line in f.readlin ...