Chapter 11-Creating Other Schema Objects ---Index

本文详细介绍了Oracle数据库中索引的作用、类型、创建方法及优化指南,包括如何根据具体情况选择创建唯一索引或非唯一索引,以及在何种场景下创建或删除索引能提高查询性能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Indexes是可选项,可有可无;它存在的价值就是improves the performance of some queries.

An index:

  • Is a schema object Can be used by the Oracle server to speed up the retrieval of rows by using a pointer
  • Can reduce disk input/output(I/O) by using a rapid path access method to locate data quickly
  • Is independent of the table that it indexes
  • Is used and maintained automatically by the Oracle server.

How are indexes created ?

two methods:  

  |-Auto  

  |-Manu Automatically:

A unique index is created automatically when you define a PRIMARY KEY or UNIQUE constraint in a table definition.

Manually:Users can create nonunique indexes on columns to speed up access to the rows.

Index category  

  |-unique index  

  |-nonunique index  

Creating an index

Create an index on one or more columns:

CREATE [UNIQUE] [BITMAP] INDEX index ON table (column,[,column]...);

Improve the speed of query access to the LAST_NAME column in the EMPLOYEES table: 

CREATE INDEX emp_last_name_idx ON employees(last_name);

Index creation guidelines

Create an index when:

  • A column contains a wide range of values
  • A column contains a large number of null values One or more columns are frequently used togerther in a WHERE cluase or join condition
  • The table is large and most queries are expected to retrieve less than 2% to 4% the rows in the table

Do not create an index when:

  • The column are not often used as a condition in the query
  • The table is small or most queries are expected to retrieve more than 2% to 4% of the rows in the table
  • The table is updated frequently
  • The indexed columns are referenced as part of an expression.

Removing an index

Remove an index from the data dictionary by using the DROP INDEX command: DROP INDEX index

Remove the emp_last_name_idx index from the data dictionary DROP INDEX EMP_LAST_NAME_IDX;

To drop an index,you must be the owner of the index or have the DROP ANY INDEX privilege.

转载于:https://www.cnblogs.com/arcer/archive/2013/04/11/3015157.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值