• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DropTableStatement类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中liquibase.statement.core.DropTableStatement的典型用法代码示例。如果您正苦于以下问题:Java DropTableStatement类的具体用法?Java DropTableStatement怎么用?Java DropTableStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DropTableStatement类属于liquibase.statement.core包,在下文中一共展示了DropTableStatement类的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(RemoveChangeSetRanStatusStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ChangeSet changeSet = statement.getChangeSet();
    String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(database.escapeObjectName("ID", Column.class) + " != ? " +
                    "AND " + database.escapeObjectName("FILENAME", Column.class) + " != ?")
            .addWhereParameters(changeSet.getId(), changeSet.getFilePath());

    return CustomSqlGenerator.generateSql(database,
            createTableAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tmpTable, tableName));
}
 

开发者ID:eselyavka,
项目名称:liquibase-impala,
代码行数:19,
代码来源:HiveRemoveChangeSetRanStatusGenerator.java

示例2: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    String tableNameEscaped = database.escapeObjectName(tableName, Table.class);
    String dateColumnNameEscaped = database.escapeObjectName("DATEEXECUTED", Column.class);
    String tagColumnNameEscaped = database.escapeObjectName("TAG", Column.class);
    String tempTable = UUID.randomUUID().toString().replaceAll("-", "");
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tempTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " NOT IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") " +
                    "FROM " + tableNameEscaped + ")");
    InsertAsSelectStatement insertAsSelectStatement = new InsertAsSelectStatement(catalogName, schemaName, tableName, tempTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "'" + statement.getTag() + "'", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(tableNameEscaped + "." + dateColumnNameEscaped + " IN (SELECT MAX(" + tableNameEscaped + "." + dateColumnNameEscaped + ") FROM " + tableNameEscaped + ") AND ("
                    + tableNameEscaped + "." + tagColumnNameEscaped + " IS NULL OR " + tableNameEscaped + "." + tagColumnNameEscaped + " != ?)").addWhereParameters(statement.getTag());

    return CustomSqlGenerator.generateSql(database,
            createTableAsSelectStatement,
            insertAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tempTable, tableName));
}
 

开发者ID:eselyavka,
项目名称:liquibase-impala,
代码行数:25,
代码来源:HiveTagDatabaseGenerator.java

示例3: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(RemoveChangeSetRanStatusStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ChangeSet changeSet = statement.getChangeSet();
    String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(" NOT (" + database.escapeObjectName("ID", Column.class) + " = ? " +
                    "AND " + database.escapeObjectName("FILENAME", Column.class) + " = ?)")
            .addWhereParameters(changeSet.getId(), changeSet.getFilePath());

    return CustomSqlGenerator.generateSql(database,
            UserSessionSettings.syncDdlStart(),
            createTableAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tmpTable, tableName),
            UserSessionSettings.syncDdlStop());
}
 

开发者ID:eselyavka,
项目名称:liquibase-impala,
代码行数:21,
代码来源:ImpalaRemoveChangeSetRanStatusGenerator.java

示例4: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
public Sql[] generateSql(DropTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    StringBuffer buffer = new StringBuffer();
    buffer.append("DROP TABLE ").append(database.escapeTableName(statement.getSchemaName(), statement.getTableName()));
    if (statement.isCascadeConstraints()) {
        if (!database.supportsDropTableCascadeConstraints()) {
            LogFactory.getLogger().warning("Database does not support drop with cascade");
        } else if (database instanceof OracleDatabase) {
            buffer.append(" CASCADE CONSTRAINTS");
        } else {
            buffer.append(" CASCADE");
        }
    }

    return new Sql[]{
            new UnparsedSql(buffer.toString())
    };
}
 

开发者ID:hongliangpan,
项目名称:manydesigns.cn,
代码行数:18,
代码来源:DropTableGenerator.java

示例5: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(final DropTableStatement statement, final Database database,
      final SqlGeneratorChain sqlGeneratorChain) {
   final StringBuilder sql = new StringBuilder();
   sql.append("DELETE FROM user_sdo_geom_metadata ");
   sql.append("WHERE table_name = '").append(
         database.correctObjectName(statement.getTableName(), Table.class));
   sql.append("'");
   final UnparsedSql deleteMetadata = new UnparsedSql(sql.toString(),
         new View().setName("user_sdo_geom_metadata"));

   // First delete the record then perform the standard behavior.
   final List<Sql> list = new ArrayList<Sql>();
   list.add(deleteMetadata);
   list.addAll(Arrays.asList(sqlGeneratorChain.generateSql(statement, database)));
   return list.toArray(new Sql[list.size()]);
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:18,
代码来源:DropSpatialTableGeneratorOracle.java

示例6: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(final DropTableStatement statement, final Database database,
      final SqlGeneratorChain sqlGeneratorChain) {
   final List<Sql> list = new ArrayList<Sql>();
   String schemaName = statement.getSchemaName();
   if (schemaName == null) {
      schemaName = database.getDefaultSchemaName();
   }
   final String tableName = statement.getTableName();

   // If the table has a geometry column, drop it first.
   if (GeometryColumnsUtils.hasGeometryColumn(database, schemaName, tableName)) {
      dropSpatialIndexIfExists(statement.getCatalogName(), schemaName, tableName, database, list);
      final String sql = "CALL DropGeometryColumns('" + schemaName + "', '" + tableName + "')";
      final Sql addGeometryColumn = new UnparsedSql(sql);
      list.add(addGeometryColumn);
   }
   list.addAll(Arrays.asList(sqlGeneratorChain.generateSql(statement, database)));
   return list.toArray(new Sql[list.size()]);
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:21,
代码来源:DropSpatialTableGeneratorGeoDB.java

示例7: testGenerateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
/**
 * Tests
 * {@link DropSpatialTableGeneratorOracle#generateSql(DropTableStatement, Database, SqlGeneratorChain)}
 */
@Test
public void testGenerateSql() {
   final DropSpatialTableGeneratorOracle generator = new DropSpatialTableGeneratorOracle();
   final Database database = new OracleDatabase();
   final SqlGeneratorChain sqlGeneratorChain = mock(SqlGeneratorChain.class);
   final DropTableStatement statement = new DropTableStatement("catalog_name", "schema_name",
         "table_name", true);
   final Sql comment = new SingleLineComment("No-op", "--");
   when(sqlGeneratorChain.generateSql(statement, database)).thenReturn(new Sql[] { comment });
   final Sql[] result = generator.generateSql(statement, database, sqlGeneratorChain);
   assertNotNull(result);
   assertEquals(result.length, 2);
   assertEquals(result[1], comment);

   // Verify the DELETE statement.
   final String deleteSql = result[0].toSql();
   String deletePattern = "(?i)DELETE FROM user_sdo_geom_metadata ";
   deletePattern += "WHERE table_name = '" + statement.getTableName().toUpperCase();
   deletePattern += "'";
   assertTrue(deleteSql.matches(deletePattern), "'" + deleteSql
         + "' does not match the pattern '" + deletePattern + "'");
   assertNotNull(result[0].getAffectedDatabaseObjects());
   assertTrue(result[0].getAffectedDatabaseObjects().size() >= 1, result[0]
         .getAffectedDatabaseObjects().toString());
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:30,
代码来源:DropSpatialTableGeneratorOracleTest.java

示例8: generateSql

点赞 3

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
public Sql[] generateSql(DropTableStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
        if (!supports(statement, database)) {
            return sqlGeneratorChain.generateSql(statement, database);
        }

        StringBuffer buffer = new StringBuffer();
        buffer.append("DROP TABLE ")
              .append(database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()));
        if (statement.isCascadeConstraints()) {
            buffer.append(" CASCADE");
        }
//        else {
//            buffer.append(" RESTRICT");
//        }

        return new Sql[]{
                new UnparsedSql(buffer.toString(), getAffectedTable(statement))
        };
    }
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:20,
代码来源:DropTableGeneratorHanaDB.java

示例9: destroy

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public void destroy() throws DatabaseException {
    Database database = getDatabase();
    try {
        if (SnapshotGeneratorFactory.getInstance().has(new Table().setName(database.getDatabaseChangeLogTableName()).setSchema(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName()), database)) {
            ExecutorService.getInstance().getExecutor(database).execute(new DropTableStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName(), false));
        }
        reset();
    } catch (InvalidExampleException e) {
        throw new UnexpectedLiquibaseException(e);
    }
}
 

开发者ID:eselyavka,
项目名称:liquibase-impala,
代码行数:13,
代码来源:HiveStandardChangeLogHistoryService.java

示例10: generateSql

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(TagDatabaseStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    String catalogName = database.getLiquibaseCatalogName();
    String schemaName = database.getDefaultSchemaName();
    String tableName = database.getDatabaseChangeLogTableName();
    String tableNameEscaped = database.escapeTableName(catalogName, schemaName, tableName);
    String dateColumnNameEscaped = database.escapeObjectName("DATEEXECUTED", Column.class);
    String tagColumnNameEscaped = database.escapeObjectName("TAG", Column.class);
    String tmpTable = UUID.randomUUID().toString().replaceAll("-", "");
    CreateTableAsSelectStatement createTableAsSelectStatement = new CreateTableAsSelectStatement(catalogName, schemaName, tableName, tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "TAG", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(dateColumnNameEscaped + " != (SELECT MAX(" + dateColumnNameEscaped + ") " +
                    "FROM " + tableNameEscaped + ")");
    InsertAsSelectStatement insertAsSelectStatement = new InsertAsSelectStatement(database.getLiquibaseCatalogName(), database.getLiquibaseSchemaName(), database.getDatabaseChangeLogTableName(), tmpTable)
            .addColumnNames("ID", "AUTHOR", "FILENAME", "DATEEXECUTED", "ORDEREXECUTED", "EXECTYPE", "MD5SUM", "DESCRIPTION", "COMMENTS", "'" + statement.getTag() + "'", "LIQUIBASE", "CONTEXTS", "LABELS", "DEPLOYMENT_ID")
            .setWhereCondition(dateColumnNameEscaped + " = (SELECT MAX(" + dateColumnNameEscaped + ") FROM " + tableNameEscaped + ") AND ("
                    + tagColumnNameEscaped + " IS NULL OR " + tagColumnNameEscaped + " != ?)")
            .addWhereParameters(statement.getTag());

    return CustomSqlGenerator.generateSql(database,
            UserSessionSettings.syncDdlStart(),
            createTableAsSelectStatement,
            insertAsSelectStatement,
            new DropTableStatement(catalogName, schemaName, tableName, false),
            new RenameTableStatement(catalogName, schemaName, tmpTable, tableName),
            UserSessionSettings.syncDdlStop());
}
 

开发者ID:eselyavka,
项目名称:liquibase-impala,
代码行数:28,
代码来源:ImpalaTagDatabaseGenerator.java

示例11: generateStatements

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
    boolean constraints = false;
    if (isCascadeConstraints() != null) {
        constraints = isCascadeConstraints();
    }
    
    return new SqlStatement[]{
            new DropTableStatement(getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(), getTableName(), constraints)
    };
}
 

开发者ID:hongliangpan,
项目名称:manydesigns.cn,
代码行数:11,
代码来源:DropTableChange.java

示例12: testSupports

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
/**
 * Tests {@link DropSpatialTableGeneratorOracle#supports(CreateSpatialIndexStatement, Database)}
 */
@Test
public void testSupports() {
   final DropSpatialTableGeneratorOracle generator = new DropSpatialTableGeneratorOracle();
   final DropTableStatement statement = mock(DropTableStatement.class);
   assertTrue(generator.supports(statement, new OracleDatabase()));
   assertFalse(generator.supports(statement, new H2Database()));
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:11,
代码来源:DropSpatialTableGeneratorOracleTest.java

示例13: testDropTableNoSchema

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Test
public void testDropTableNoSchema() {
    Database database = new HanaDBDatabase();
    DropTableStatement statement = new DropTableStatement(null, null, "table_name", false);

    assertEquals("DROP TABLE \"table_name\"",
            this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:9,
代码来源:DropTableGeneratorHanaDBTest.java

示例14: testDropTableAndCascadeWithSchema

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Test
public void testDropTableAndCascadeWithSchema() {
    Database database = new HanaDBDatabase();
    DropTableStatement statement = new DropTableStatement(null, "schema_name", "table_name", true);

    assertEquals("DROP TABLE \"schema_name\".\"table_name\" CASCADE",
            this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:9,
代码来源:DropTableGeneratorHanaDBTest.java

示例15: dropDatabaseChangeLogTable

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
private void dropDatabaseChangeLogTable(String catalog, String schema, Database database) {
    try {
        ExecutorService.getInstance().getExecutor(database).execute(new DropTableStatement(catalog, schema, database.getDatabaseChangeLogTableName(), false));
    } catch (DatabaseException e) {
        ; //ok
    }
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:8,
代码来源:AbstractIntegrationTest.java

示例16: validate

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
public ValidationErrors validate(DropTableStatement dropTableStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("tableName", dropTableStatement.getTableName());
    return validationErrors;
}
 

开发者ID:hongliangpan,
项目名称:manydesigns.cn,
代码行数:6,
代码来源:DropTableGenerator.java

示例17: supports

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public boolean supports(final DropTableStatement statement, final Database database) {
   return database instanceof OracleDatabase;
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:5,
代码来源:DropSpatialTableGeneratorOracle.java

示例18: validate

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public ValidationErrors validate(final DropTableStatement statement, final Database database,
      final SqlGeneratorChain sqlGeneratorChain) {
   return sqlGeneratorChain.validate(statement, database);
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:6,
代码来源:DropSpatialTableGeneratorOracle.java

示例19: supports

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
/**
 * @see AbstractSqlGenerator#supports(SqlStatement, Database)
 */
@Override
public boolean supports(final DropTableStatement statement, final Database database) {
   return database instanceof DerbyDatabase || database instanceof H2Database;
}
 

开发者ID:lonnyj,
项目名称:liquibase-spatial,
代码行数:8,
代码来源:DropSpatialTableGeneratorGeoDB.java

示例20: supports

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
public boolean supports(DropTableStatement statement, Database database) {
    return database instanceof HanaDBDatabase;
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:5,
代码来源:DropTableGeneratorHanaDB.java

示例21: DropTableGeneratorHanaDBTest

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
protected DropTableGeneratorHanaDBTest(SqlGenerator<DropTableStatement> generatorUnderTest) throws Exception {
    super(generatorUnderTest);
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:4,
代码来源:DropTableGeneratorHanaDBTest.java

示例22: createSampleSqlStatement

点赞 2

import liquibase.statement.core.DropTableStatement; //导入依赖的package包/类
@Override
protected DropTableStatement createSampleSqlStatement() {
       Database database = new HanaDBDatabase();
       DropTableStatement dropTableStatement = new DropTableStatement(null, null, "table_name", false);
       return dropTableStatement;
   }
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:7,
代码来源:DropTableGeneratorHanaDBTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)