How to drop index and before dropping it how to get the DDL.

 

Oracle DROP INDEX statement




DROP INDEX [schema_name.]index_name;

DECLARE index_count INTEGER; BEGIN SELECT COUNT(*) INTO index_count FROM USER_INDEXES WHERE INDEX_NAME = 'index_name'; IF index_count > 0 THEN EXECUTE IMMEDIATE 'DROP INDEX index_name'; END IF; END; /

In case want to check whether index exists and then delete it.

If try to drop a non-existing, you will get the following error:

SQL Error: ORA-01418: specified index does not exist

In SQLplus, set these before running the commands

set long 100000
set longchunksize 100000
select DBMS_METADATA.GET_DDL('INDEX', 'index_name') 
from all_indexes 
where owner in (USER, 'USER_OTHER_THAN_LOGGED_IN_USER');
Use below script to fetch metadata other information.
SELECT DBMS_METADATA,GET_GRANTED_DDL('SYSTEM_GRANT','SSO******') from dual;

Comments

Popular posts from this blog

PRVG-11250 : The check "RPM Package Manager database" was not performed because

How to troubleshoot Long Running Concurrent Request in EBS 12.2

ORA-00257:archiver error, connect internal only until freed

Verifying Daemon “Avahi-Daemon” Not Configured And Running …FAILED (PRVG-1360)

Linux OL7/RHEL7: PRVE-0421 : No entry exists in /etc/fstab for mounting /dev/shm

CPU Patch Analysis

How to write to a CSV file using Oracle SQL*Plus

SKIP DNS RESLOV.CONF CHECK DURING RAC CONFIGURATION

How to fix Oracle SQL Developer connection issue "Got minus one from a read call"