--去重查询方法一:根据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. 完整卸载 kubuntu-desktop from Ubuntu 14.04 LTS

    系统 ubuntu 14.04 LTS 64Bit 目的:卸载kubuntu-desktop 方法一: sudo apt-get remove libkde3support4 k3b-data ntr ...

  2. 怎么找到占用usb的模块,linux下Jlink连接失败

    问题是这样产生的,我在linux下安装jlink,启动JLinkExe执行,总是提示不能通过usb连接: SEGGER J-Link Commander V5.10q (Compiled Mar :: ...

  3. Flex数据绑定陷阱(一)

    Flex数据绑定陷阱:常见的误用和错误 当构建Flex或者Adobe AIR程序时,将一个对象的值自动的传递给另一个对象这种处理是数据绑定最常 用并最有用的特征之一. 尽管如此,同时数据绑定会减缓程序 ...

  4. CSS中的常用属性

    一 CSS文字属性:color : #999999; /*文字颜色*/font-family : 宋体,sans-serif; /*文字字体*/font-size : 9pt; /*文字大小*/fon ...

  5. SQL存储过程的调用及写法

    调用函数: public class SqlProcess { ; public DataSet ReturnSet = null; public SqlDataAdapter adapter = n ...

  6. [No000051]如何去掉word复制过来的文字背景色?

    我们经常从网上copy一些自己需要的材料到word里.不过常常会把别人的背景色一起拷贝过来.那么如何去掉word复制过来的文字背景色? 方法/步骤 第一步选ctrl+A(全选),找到页面布局→页面边框 ...

  7. 用AutoCompleteTextView实现历史记录提示

    自定义AutoCompleteTextView 博客分类: android进阶 android  网上找到的都是同ArrayAdapter一起使用的,有时候需要自定义风格,咋办?follow me! ...

  8. Java手动添加SSL证书

    出现错误为 SSLHandshakeException - unable to find valid certification path to requested target 在服务器上找到对应的 ...

  9. JS 中如何判断 undefined 和 null

    JS 中如何判断 undefined JavaScript 中有两个特殊数据类型:undefined 和 null,下节介绍了 null 的判断,下面谈谈 undefined 的判断. 以下是不正确的 ...

  10. 简单创建与布署CLR存储过程

    今天的博文是学习CLR存储过程,一个简单的例子,学会怎样创建,编译,布署在SQL中.CLR能做一些T-SQL无法做的事情,很多情况之后,它比T-SQL快. 打开VS2013,创建一个新专案,参考下面5 ...