The DropSchema class of the SQL Statement Builder provides an entry point to defining a DROP SCHEMA SQL statement.
-
Create an instance of the
DropSchemaclass through theStatementFactoryDropSchema dropSchema = StatementFactory.getInstance().dropSchema("schemaName");
-
Add available options using fluent programming if necessary.
The following options are currently supported:
IF EXISTSCASCADERESTRICT
Example:
dropSchema.ifExists().cascade();
Please do not use methods
cascade()andrestrict()on the same object. If both these options are used on the same object,IllegalArgumentExceptionwill be thrown. -
Render the instance of
DropSchemaclass. Click here for more information on Rendering SQL Statement.- The complete example code
DropSchema dropSchema = StatementFactory.getInstance().dropSchema("schemaName"); // optional step: add additional clauses dropSchema.ifExists().cascade(); // or dropSchema.ifExists().restrict(); // Rendering // optional step: add configuration StringRendererConfig config = StringRendererConfig.builder().lowerCase(true).build(); DropSchemaRenderer renderer = DropSchemaRenderer.create(config); dropSchema.accept(renderer); String renderedString = renderer.render();