本文整理汇总了Java中liquibase.statement.core.RenameColumnStatement类的典型用法代码示例。如果您正苦于以下问题:Java RenameColumnStatement类的具体用法?Java RenameColumnStatement怎么用?Java RenameColumnStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RenameColumnStatement类属于liquibase.statement.core包,在下文中一共展示了RenameColumnStatement类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSql
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
public Sql[] generateSql(RenameColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String sql;
if (database instanceof MSSQLDatabase) {
// do no escape the new column name. Otherwise it produce "exec sp_rename '[dbo].[person].[usernae]', '[username]'"
sql = "exec sp_rename '" + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + "." + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + "', '" + statement.getNewColumnName() + "'";
} else if (database instanceof MySQLDatabase) {
sql ="ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " CHANGE " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName()) + " " + statement.getColumnDataType();
} else if (database instanceof HsqlDatabase || database instanceof H2Database) {
sql ="ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " ALTER COLUMN " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " RENAME TO " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
} else if (database instanceof FirebirdDatabase) {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " ALTER COLUMN " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " TO " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
} else if ((database instanceof MaxDBDatabase)
// supported in Derby from version 10.3.1.4 (see "http://issues.apache.org/jira/browse/DERBY-1490")
|| (database instanceof DerbyDatabase)
|| (database instanceof InformixDatabase)) {
sql = "RENAME COLUMN " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + "." + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " TO " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
} else if (database instanceof SybaseASADatabase) {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " RENAME " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " TO " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
} else {
sql = "ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " RENAME COLUMN " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) + " TO " + database.escapeColumnName(statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
}
return new Sql[] {
new UnparsedSql(sql)
};
}
示例2: validate
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
public ValidationErrors validate(RenameColumnStatement renameColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", renameColumnStatement.getTableName());
validationErrors.checkRequiredField("oldColumnName", renameColumnStatement.getOldColumnName());
validationErrors.checkRequiredField("newColumnName", renameColumnStatement.getNewColumnName());
if (database instanceof MySQLDatabase) {
validationErrors.checkRequiredField("columnDataType", renameColumnStatement.getColumnDataType());
}
return validationErrors;
}
示例3: generateStatements
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
//todo if (database instanceof SQLiteDatabase) {
// // return special statements for SQLite databases
// return generateStatementsForSQLiteDatabase(database);
// }
return new SqlStatement[] { new RenameColumnStatement(
getSchemaName() == null?database.getDefaultSchemaName():getSchemaName(),
getTableName(), getOldColumnName(), getNewColumnName(),
getColumnDataType())
};
}
示例4: generateSql
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
/**
* @see liquibase.sqlgenerator.core.RenameColumnGenerator#generateSql(liquibase.statement.core.RenameColumnStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
*/
@Override
public Sql[] generateSql(RenameColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
String sql = "ALTER TABLE " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName())
+ " RENAME " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName())
+ " TO " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
return new Sql[] {
new UnparsedSql(sql)
};
}
示例5: validate
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public ValidationErrors validate(RenameColumnStatement renameColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
ValidationErrors validationErrors = new ValidationErrors();
validationErrors.checkRequiredField("tableName", renameColumnStatement.getTableName());
validationErrors.checkRequiredField("oldColumnName", renameColumnStatement.getOldColumnName());
validationErrors.checkRequiredField("newColumnName", renameColumnStatement.getNewColumnName());
return validationErrors;
}
示例6: generateSql
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(RenameColumnStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
if (!supports(statement, database)) {
return sqlGeneratorChain.generateSql(statement, database);
}
String sql;
sql = "RENAME COLUMN " + database.escapeTableName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName()) +
"." + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getOldColumnName()) +
" TO " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getNewColumnName());
return new Sql[] {
new UnparsedSql(sql, getAffectedOldColumn(statement), getAffectedNewColumn(statement))
};
}
示例7: createSampleSqlStatement
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
protected RenameColumnStatement createSampleSqlStatement() {
Database database = new HanaDBDatabase();
RenameColumnStatement renameColumnStatement = new
RenameColumnStatement(null, null, "table_name", "old_column_name", "new_column_name", null);
return renameColumnStatement;
}
示例8: testRenameColumnNoSchema
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Test
public void testRenameColumnNoSchema() {
Database database = new HanaDBDatabase();
RenameColumnStatement statement = new
RenameColumnStatement(null, null, "table_name", "old_column_name", "new_column_name", null);
assertEquals("RENAME COLUMN \"table_name\".\"old_column_name\" TO \"new_column_name\"",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
示例9: testRenameColumnWithSchema
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Test
public void testRenameColumnWithSchema() {
Database database = new HanaDBDatabase();
RenameColumnStatement statement = new
RenameColumnStatement(null, "schema_name", "table_name", "old_column_name", "new_column_name", "int(11) unsigned");
assertEquals("RENAME COLUMN \"schema_name\".\"table_name\".\"old_column_name\" TO \"new_column_name\"",
this.generatorUnderTest.generateSql(statement, database, null)[0].toSql());
}
示例10: supports
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(RenameColumnStatement statement, Database database) {
return !(database instanceof DB2Database
|| database instanceof CacheDatabase
|| database instanceof SQLiteDatabase);
}
示例11: supports
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(RenameColumnStatement statement, Database database) {
return database instanceof TeradataDatabase;
}
示例12: supports
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(RenameColumnStatement statement, Database database) {
return database instanceof HanaDBDatabase;
}
示例13: RenameColumnGeneratorHanaDBTest
import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
protected RenameColumnGeneratorHanaDBTest(SqlGenerator<RenameColumnStatement> generatorUnderTest) throws Exception {
super(generatorUnderTest);
}