Friday, May 11, 2012

how to extract the definitions of indexes in an Oracle export file without connection to the database

Today I found myself in a situation where I needed definitions of indexes of an Oracle 9i database, but everything I had on me was an export file and no access to a database.

I discovered a simple way and without connection to a database to extract the definitions of indexes from an export file of an ORACLE database running on AIX 6.1

grep "CREATE INDEX" export_file.dmp > indexes_files.sql

This unix command will extract the indexes definition from the export file export_file.dmp and save it in a sql file indexes_files.sql

After that i needed to reformat the sql file and include a slash (/) after every definition in the file

cat achats_indexes.sql | awk '$0=$0 " \n/" {print $0}' >> output_indexes_files.sql

That's all, you can combine these two commands to create a shell script to extract indexes definition from oracle export files, taking 2 parameters : the export file and the sql output file.


No comments:

Post a Comment