Answers for "unusable index in oracle"

SQL
2

oracle find unusable indexes

SELECT OWNER, INDEX_NAME, NULL AS PARTITION_NAME, NULL AS SUBPARTITION_NAME, TABLESPACE_NAME
FROM DBA_INDEXES
WHERE STATUS = 'UNUSABLE'
UNION ALL	-- Index partitions:
SELECT INDEX_OWNER, INDEX_NAME, PARTITION_NAME, NULL AS SUBPARTITION_NAME, TABLESPACE_NAME
FROM DBA_IND_PARTITIONS
WHERE STATUS = 'UNUSABLE'
UNION ALL	-- Index subpartitions:
SELECT INDEX_OWNER, INDEX_NAME, PARTITION_NAME, SUBPARTITION_NAME, TABLESPACE_NAME
FROM DBA_IND_SUBPARTITIONS
WHERE STATUS = 'UNUSABLE';
Posted by: Guest on March-08-2021
1

oracle rebuild unusable indexes

-- Indexes:
SELECT 'alter index ' || OWNER || '.' || INDEX_NAME || ' rebuild tablespace ' 
	|| TABLESPACE_NAME || ';' SQL_TO_REBUILD_INDEX FROM DBA_INDEXES
WHERE STATUS = 'UNUSABLE';
-- Index partitions:
SELECT 'alter index ' || INDEX_OWNER || '.' || INDEX_NAME 
	|| ' rebuild partition ' || PARTITION_NAME || ' TABLESPACE ' 
    || TABLESPACE_NAME || ';' SQL_TO_REBUILD_INDEX
FROM DBA_IND_PARTITIONS WHERE STATUS = 'UNUSABLE';
-- Index subpartitions:
SELECT 'alter index ' || INDEX_OWNER || '.' || INDEX_NAME 
	|| ' rebuild subpartition ' || SUBPARTITION_NAME || ' TABLESPACE ' 
    || TABLESPACE_NAME || ';' SQL_TO_REBUILD_INDEX
FROM DBA_IND_SUBPARTITIONS WHERE STATUS = 'UNUSABLE';
Posted by: Guest on March-08-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language