Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 
 

Oracle Create Index tips

Oracle Tips by Burleson Consulting

Creating Oracle Indexes

Once you have decided you need to create an index you use the create index command. The command is pretty straightforward as seen in this example:

CREATE INDEX
   ix_emp_01
ON
   emp (deptno)
TABLESPACE
   index_tbs;

This statement creates an index called IX_EMP_01. This index is built on the DEPTNO column of the EMP table. We also defined the tablespace that the index should be created in using the tablespace keyword, in this case we created it in the INDEX_TBS tablespace.

You can create indexes on multiple columns in a table. Say, for example, we wanted an index on the EMP table columns EMPNO and DEPTNO. This is known as a concatenated index, and it?s created this way:

CREATE INDEX ix_emp_01 ON emp (empno, deptno) TABLESPACE index_tbs;

Altering Oracle Indexes

If we create indexes, there may be times that we will want to change some attribute of that index, such as where it is stored. Also, sometimes an index needs to be rebuilt to help with performance. For cases like these, the alter index command is what we want.

Let?s look at an example of the use of the alter index command:

ALTER INDEX ix_emp_01 REBUILD TABLESPACE new_index;

In this example we use the alter index command to rebuild an index. The rebuild keyword is what tells Oracle to rebuild the index. When we use the tablespace keyword, followed by a tablespace name, we are telling Oracle which tablespace to recreate the rebuilt index in. By default Oracle will create the rebuilt index in the same tablespace.

The alter index command allows you to rename an index using the rename to keyword as seen in this example:

ALTER INDEX ix_emp_01 RENAME TO ix_emp_01_old;

In this case we have renamed the ix_emp_01 index to ix_emp_01_old. All of the data dictionary entries will be changed by Oracle to reflect the new name (we will discuss indexes and the data dictionary in a moment)

Dropping Oracle Indexes

Sometimes what we create we must destroy. When it?s time to remove an index, the drop index command is what is needed. The drop index command is pretty straight forward as seen in this example:

DROP INDEX ix_emp_01_old;

Generate create index syntax

You can punch create index DDL syntax is using the dbms_metadata package, something like this:

select
   dbms_metadata.get_ddl('INDEX',index_name)
from
   user_indexes
where
   xxxx;

For more information on creating indexes see these articles:

This is an excerpt from the bestselling "Easy Oracle Jumpstart" by Robert Freeman and Steve Karam (Oracle ACE and Oracle Certified Master).  It?s only $19.95 when you buy it directly from the publisher here.

If you like Oracle tuning, you may enjoy the new book "Oracle Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning tips & scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.