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)
     
  • 相关阅读:
    函数式语言(老师作业)
    session/cookie
    Linux根目录下各个目录的功能介绍
    Navicat12安装文件和破解补丁
    正则表达式验证示例
    RequestDispatcher接口示例
    hello2部分源码解析
    Introduction of Servlet Filter
    关于hello1中的web.xml解析
    Annotation解释
  • 原文地址:https://www.cnblogs.com/aknife/p/10745409.html
Copyright © 2011-2022 走看看