Home > Ask the Oracle Experts > Database Backup and Recovery Questions & Answers > How to create an index using a procedure in Oracle
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

How to create an index using a procedure in Oracle

Brian Peasland EXPERT RESPONSE FROM: Brian Peasland

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 21 June 2007
How can we create an index using a procedure?

>
EXPERT RESPONSE

You'll have to use dynamic SQL and the EXECUTE IMMEDIATE command to create the index in the procedure. Such a stored procedure may look like the following:

CREATE PROCEDURE my_pro
AS
  stmt  VARCHAR2(200);
BEGIN
  stmt := 'CREATE INDEX my_index ON my_table(columnZ)';
  EXECUTE IMMEDIATE stmt;
END;
/
From the above, it should be easy to modify the code for your situation.

I would caution you that creating objects on the fly is normally considered a bad practice and is usually the result of a poor database design. So make sure you have a well-designed database schema before implementing this procedure.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Database Backup and Recovery
Is a hot backup part of a backup database using RMAN?
How does Oracle instance recovery work and what happens internally?
How to back up Oracle 10g RAC database on an AIX system
How to configure Oracle DB_BLOCK_SIZE and Solaris operating system block size
Tips for using parameters in an Oracle dump file import
Which backup strategy should I use for my Oracle 10g database?
RMAN catalog backup: One catalog vs. multiple catalogs
Can I use Oracle FTP for importing data from Oracle 11g into 10g?
When to use the Oracle ANALYZE command and how to avoid complications
How to complete an Oracle installation on Linux

Oracle database design
Oracle database in the cloud floated at Harvard lab
Oracle OpenWorld 2008 Special Report
Weighing remote database administration pros and cons takes care
Oracle Database 11g makes waves at Burlington Coat Factory
How to create a database link in Oracle
Data modeling tools no substitute for hard work
How do I do that in Oracle?
The Oracle Database user's guide to Oracle OpenWorld 2007
Oracle OpenWorld 2007 Special Report
How many redo log files?

Oracle stored procedures
Stored procedure to autotransfer data between Oracle servers
Insufficient privileges error when creating stored procedure
ORA-01422 error when procedure returns more than one row
Calling procedure inside another procedure in anonymous block
Can I make a second connection to Oracle without losing the first?
Oracle updates Microsoft developer tools
Procedure compiles but does not execute
Tool in Oracle 10g to keep track of execution of queries
ORA-04082: NEW or OLD references not allowed in table level triggers
Execute SQL statement from table in other schema

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
extent  (SearchOracle.com)
field  (SearchOracle.com)
flexfield  (SearchOracle.com)
foreign key  (SearchOracle.com)
quad tree  (SearchOracle.com)
record  (SearchOracle.com)
row  (SearchOracle.com)
splay tree  (SearchOracle.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts