void dropIndex ( String indexName ) { Index index ; index = table . getIndex ( indexName ) ; if ( table . isIndexingMutable ( ) ) { table . dropIndex ( session , indexName ) ; } else { OrderedHashSet indexSet = new OrderedHashSet ( ) ; indexSet . add ( table . getIndex ( indexName ) . getName ( ) ) ; Table tn = table . moveDefinition ( session , table . tableType , null , null , null , - 1 , 0 , emptySet , indexSet ) ; tn . moveData ( session , table , - 1 , 0 ) ; updateConstraints ( tn , emptySet ) ; setNewTableInSchema ( tn ) ; database . persistentStoreCollection . releaseStore ( table ) ; table = tn ; } if ( ! index . isConstraint ( ) ) { database . schemaManager . removeSchemaObject ( index . getName ( ) ) ; } database . schemaManager . recompileDependentObjects ( table ) ; }
Because of the way indexes and column data are held in memory and on disk it is necessary to recreate the table when an index is added to or removed from a non - empty table .