HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Get the DDL for all indexes - Oracle

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
theallindexesddlgetfororacle

Problem

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.!

Solution

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');

Code Snippets

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');

Context

StackExchange Database Administrators Q#116414, answer score: 7

Revisions (0)

No revisions yet.