zoukankan      html  css  js  c++  java
  • Oracle day05 索引_数据去重

    索引
    自动:当在表上定义一个primary key或者unique 约束条件时,oracle数据库自动创建一个对应的唯一索引.
    手动:用户可以创建索引以加速查询
    在一列或者多列上创建索引:
    create index index on table (column[,column]...);
    下面的索引将会提高对emp表基于ename字段的查询速度
    create index emp_last_name_idx on emp(ename)
    通过drop index 命令删掉一个索引
    drop index index
    删掉upper_last_name_idx索引
    drop index upper_last_name_idx;
     
    Top-N
    语法:
    select [column_list],rownum from (select [column_list] from table order by top-n_column) where rownum<=n;
    rowid
    rowid是oracle 实际存在的值,是唯一的值
    rownum是一个虚拟的顺序值,前提是一定要排序
    select emp.* ,rowid from emp;
     
    delect from emp e where rowid not in(select min(rowid) from emp group by ename)

     

     
     
    删除重复数据
    如何只显示重复数据,或不显示重复数据
    显示重复:
    select * from tablename group byid having count(*)>1
    不显示重复:
    select * from tablename group byid having count(*)=1
    删除重复数据原型:
    delete from temp where rowid not in( select min(rowid) from emp group by ename having count(*)>=1)
     
  • 相关阅读:
    BZOJ2219数论之神——BSGS+中国剩余定理+原根与指标+欧拉定理+exgcd
    Luogu 3690 Link Cut Tree
    CF1009F Dominant Indices
    CF600E Lomsat gelral
    bzoj 4303 数列
    CF1114F Please, another Queries on Array?
    CF1114B Yet Another Array Partitioning Task
    bzoj 1858 序列操作
    bzoj 4852 炸弹攻击
    bzoj 3564 信号增幅仪
  • 原文地址:https://www.cnblogs.com/aknife/p/10745409.html
Copyright © 2011-2022 走看看