zoukankan      html  css  js  c++  java
  • 逆袭之旅DAY16.东软实训.Oracle.索引

    2018-07-12 14:44:27 

    四、索引
    1、创建索引
    手动创建:
    create index 索引名 on 表名(列名,[列名,...])
    create table employee(
    pno number(7),
    pname varchar2(20)
    );

    create index inx_scott_pno on employee(pno);
    insert into employee select empno,ename from emp;


    select *
    from employee
    where pno=7788;

    ---递归插入数据
    insert into employee select * from employee;

    update employee set pno = rownum;
    函数索引:
    create index inx_scott_pname on employee(upper(ename));

    create index inx_scott_pname_pno on employee(pno,pname);

    自动创建索引:当创建主键或唯一键时,会自动创建索引

    2、删除索引:
    drop index 索引名;

    drop index inx_scott

    ----练习2
    1.使用子查询的方式,创建test表。
    create table test as select * from emp;
    select * from test;


    2.快速复制test表中的数据,复制到100w条左右
    ---递增式插入
    insert into test select * from emp;
    select * from test;

    3.更新test表中的empno字段为rownum
    update test set empno=rownum;
    select * from test;

    4.查询test中empno为800000的记录值,记录查询执行时间。
    select *
    from test
    where empno=800000;

    5.在test表的empno字段上创建索引
    create index inx_scott_empno on test(empno);

    6.重新执行第4题,对比查询时间

    年轻人能为世界年轻人能为世界做些什么
  • 相关阅读:
    免费报表工具 积木报表(JiMuReport)的安装
    jeecgboot积木报表(jimuReport)SQL Server切换
    Machine Learning目录
    Pytorch05_torch安装(GPU版)
    Pytorch04_RNN结构
    Pytorch03_张量变化
    Pytorch02_GPU加速
    Pytorch01_通用结构
    怎么将本地文件上传到远程git仓库
    SpringCloud-微服务架构编码构建
  • 原文地址:https://www.cnblogs.com/twinkle-star/p/9299394.html
Copyright © 2011-2022 走看看