Get the DDL for all indexes – Oracle

ddlindexoracleoracle-12c

I have about 5 schemas in my oracle 12c database for which I need the DDL for all the indexes for each of the schemas. DDL I have checked it on how to get the code from it, but for all the indexes and for each schema in one go.. is it possible?
If yes, help me out.!

Thanks.!

Best Answer

You can use dbms_metadata for this.

select dbms_metadata.get_ddl('INDEX', index_name, owner)
from all_indexes
where owner in ('USER_1', 'USER_2', 'USER_3', 'USER_4', 'USER_5');