逆袭之旅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题,对比查询时间

转载于:https://www.cnblogs.com/twinkle-star/p/9299394.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值