Domanda

I have recently exported an Oracle database to a new environment. Unfortunately, many of the indexes failed to create. I would like to know if there is a way to generate sql for a variety of these.

For example, I know if you select a table and click the "SQL" tab on the list across the top, it will generate the sql output automatically. (See screenshot) However, I need to do this for most, if not all, the entire database. It's the indexes I'm most interested in.

http://i.imgur.com/dpcsE.jpg

È stato utile?

Soluzione

Using dbms_metadata on the source database, you can generate the DDL statements for all indexes you're interested in:

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

This will give you the DDL statements for all indexes of the currently connected user; if you want indexes for all users, use all_indexes / dba_indexes instead (the latter requires special privileges).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top