Oracle索引的使用
来源:互联网 发布:止汗露的危害 知乎 编辑:程序博客网 时间:2024/05/22 03:45
最近做数据整合,把其他服务器上的数据抽取到统一数据库中,为提高速度,考虑采用索引。
网络上搜取到的资料如下,地址:http://hi.baidu.com/luodaijun/item/e8bae5db494abdcf1b72b4ec, 后续根据需求继续补充:
1.索引分类
a) 唯一索引, 作用是数据约束,保证数据唯一,还有就是数据索引,提高查询效率
b)一般索引,只有数据索引的作用,
2.唯一索引的建立
create unique index 索引名 on 表名(字段名)
ok,假设有一个Emploeyy表,里面有一个empName字段,我们来为empName添加唯一索引
create unique index idx_empname on employee(empname);
3.一般索引
create index 索引名 on 表名(字段名)
ok,现在我们为employee的address字段,添加一般索引
create index idx_address on employee(address);
我们还可以为两多个字段建立索引
create unique index idx_test on employee(field1,field2);
这样,为field1,field2添加了唯一索引,field1和field2的组合是唯一的了
还可以指定索引排序
create index idx_test employee(field1 ,field2 desc);;
4.函数索引
如果在我们的查询条件使用了函数,那么索引就不可用了。
可以用建立函数索引的方式,来解决这个问题
例如:
select * from product where nvl(price,0.0)>1000.0 ;
这里,nvl(price,0.0)使用了函数,索引不能利用price字段上做的索引了
ok,我们来创建函数索引
create index index_price on product(nvl(price,0.0));
5.索引的删除
drop index 索引名
drop index idx_empname;
6.其它的
唯一索引能极大的提高查询速度,而且还有唯一约束的作用
一般索引,只能提高30%左右的速度
经常插入,修改,应在查询允许的情况下,尽量减少索引,因为添加索引,插入,修改等操作,需要更多的时间
可以在order by的字段,where的条件字段,join的关联字段添加索引
比如:
select * from table1 t1
left join table2 t2 on t1.字段A=t2.字段B
where t1.字段C = '值'
order by t1.字段D
这里,A,B,C,D字段,都应该添加索引
- Oracle索引的使用
- oracle的索引使用
- oracle索引的使用
- 小议Oracle索引的使用
- Oracle使用索引的好处
- Oracle索引的使用规则
- oracle的索引使用注意
- Oracle基本索引的使用
- Oracle索引(Index)的使用
- Oracle中索引的使用
- oracle索引的使用【整理】
- oracle的索引使用:复合索引中的前导索引
- Oracle 使用索引和不使用索引的举例
- Oracle中索引的使用 索引性能优化调整
- 使用ORACLE索引的一些小技巧
- oracle全文索引的创建和使用
- 小议在Oracle中索引的使用
- oracle全文索引的创建和使用
- 每日一题(49) - 最长回文子串
- .balignl的意义
- UVALive 5864 Register Allocation 解题报告
- 多校联合赛(一) 1008 Park Visit
- C语言中变量的作用域
- Oracle索引的使用
- hdu4608 - I-number(水题)
- C++拷贝构造函数(深拷贝,浅拷贝)
- java异常1
- Linux中的分段
- poj 1873 The Fortified Forest (暴力搜索+凸包求周长)
- NSTimer和CADisplayLink的用法
- jQuery给控件赋值
- [Erlang 0104] 当Erlang遇到Solr