OrderedHashSet externalReferences = new OrderedHashSet();
getCascadingSchemaReferences(schema.getName(), externalReferences);
removeSchemaObjects(externalReferences);
Iterator tableIterator =
schema.schemaObjectIterator(SchemaObject.TABLE);
while (tableIterator.hasNext()) {
Table table = ((Table) tableIterator.next());
Constraint[] list = table.getFKConstraints();
for (int i = 0; i < list.length; i++) {
Constraint constraint = list[i];
if (constraint.getMain().getSchemaName() != schema.getName()) {
constraint.getMain().removeConstraint(
constraint.getMainName().name);
}
}
removeTable(session, table);
}
Iterator sequenceIterator =
schema.schemaObjectIterator(SchemaObject.SEQUENCE);
while (sequenceIterator.hasNext()) {
NumberSequence sequence =
((NumberSequence) sequenceIterator.next());
database.getGranteeManager().removeDbObject(sequence.getName());
}
schema.clearStructures();