01: package liquibase.database.sql;
02:
03: import liquibase.database.DB2Database;
04: import liquibase.database.Database;
05: import liquibase.exception.StatementNotSupportedOnDatabaseException;
06:
07: public class ReorganizeTableStatement implements SqlStatement {
08: private String schemaName;
09: private String tableName;
10:
11: public ReorganizeTableStatement(String schemaName, String tableName) {
12: this .schemaName = schemaName;
13: this .tableName = tableName;
14: }
15:
16: public String getSchemaName() {
17: return schemaName;
18: }
19:
20: public String getTableName() {
21: return tableName;
22: }
23:
24: public String getSqlStatement(Database database)
25: throws StatementNotSupportedOnDatabaseException {
26: if (!supportsDatabase(database)) {
27: throw new StatementNotSupportedOnDatabaseException(
28: "Cannot reorganize table", this , database);
29: }
30: return "CALL SYSPROC.ADMIN_CMD ('REORG TABLE "
31: + database.escapeTableName(getSchemaName(),
32: getTableName()) + "')";
33: }
34:
35: public String getEndDelimiter(Database database) {
36: return ";";
37: }
38:
39: public boolean supportsDatabase(Database database) {
40: return database instanceof DB2Database;
41: }
42: }
|