The DropSchema
class of the SQL Statement Builder provides an entry point to defining a DROP SCHEMA
SQL statement.
-
Create an instance of the
DropSchema
class through theStatementFactory
DropSchema dropSchema = StatementFactory.getInstance().dropSchema("schemaName");
-
Add available options using fluent programming if necessary.
The following options are currently supported:
IF EXISTS
CASCADE
RESTRICT
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,IllegalArgumentException
will be thrown. -
Render the instance of
DropSchema
class. 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();