How can I obtain all the index creation statements in ORACLE ?, Oracle index creation statement

Source: Internet
Author: User

How can I obtain all the index creation statements in ORACLE ?, Oracle index creation statement

How can I obtain all the index creation statements in ORACLE?

Set pagesize 0

Sets long 90000

Set feedback off

Set echo off

Spool all_index. SQL

SELECT DBMS_METADATA.GET_DDL ('index', u. index_name)

FROM USER_INDEXES u;

Spool off;

Finally, find an editor to replace the tablespace name and add it after the tablespace name;

Then let ORACLE execute it slowly

The external process DBMS_METADATA.GET_DDL is called to obtain the DLL creation statement.

This is the DLL created by all users.

SELECT DBMS_METADATA.GET_DDL ('user', U. username)

FROM DBA_USERS U;

This is the DLL of all tables.

SELECT DBMS_METADATA.GET_DDL ('table', u. table_name)

FROM USER_TABLES u;

DLL for all tablespaces

SELECT DBMS_METADATA.GET_DDL ('tablespace', TS. tablespace_name)

FROM DBA_TABLESPACES TS;

Combine all tables and index stored procedures

SELECT DBMS_METADATA.GET_DDL (U. OBJECT_TYPE, u. object_name)

FROM USER_OBJECTS u

Where U. OBJECT_TYPE IN ('table', 'index', 'Procedure ');

Export only indexes: SELECT DBMS_METADATA.GET_DDL (U. OBJECT_TYPE, u. object_name)

FROM USER_OBJECTS u

Where U. OBJECT_TYPE IN ('index'); export as an SQL statement

Another related statement is used to generate a statement to delete all indexes of a user.

Select 'drop Index' | index_name | '; 'form user_indexes;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.