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

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

SKIP DNS RESLOV.CONF CHECK DURING RAC CONFIGURATION

CPU Patch Analysis

How to troubleshoot Long Running Concurrent Request in EBS 12.2

How To Manage Space of The FRA in the Oracle DB

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