当前位置: 首页>>代码示例>>Java>>正文


Java RenameColumnStatement类代码示例

本文整理汇总了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)
    };
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:27,代码来源:RenameColumnGenerator.java

示例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;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:RenameColumnGenerator.java

示例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())
        };
    }
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:13,代码来源:RenameColumnChange.java

示例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)
	};
}
 
开发者ID:liquibase,项目名称:liquibase-teradata,代码行数:13,代码来源:RenameColumnGeneratorTeradata.java

示例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;
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:10,代码来源:RenameColumnGeneratorHanaDB.java

示例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))
    };
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:16,代码来源:RenameColumnGeneratorHanaDB.java

示例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;
   }
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:8,代码来源:RenameColumnGeneratorHanaDBTest.java

示例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());
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:10,代码来源:RenameColumnGeneratorHanaDBTest.java

示例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());
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:10,代码来源:RenameColumnGeneratorHanaDBTest.java

示例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);
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:7,代码来源:RenameColumnGenerator.java

示例11: supports

import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(RenameColumnStatement statement, Database database) {
	return database instanceof TeradataDatabase;
}
 
开发者ID:liquibase,项目名称:liquibase-teradata,代码行数:5,代码来源:RenameColumnGeneratorTeradata.java

示例12: supports

import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
@Override
public boolean supports(RenameColumnStatement statement, Database database) {
    return database instanceof HanaDBDatabase;
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:5,代码来源:RenameColumnGeneratorHanaDB.java

示例13: RenameColumnGeneratorHanaDBTest

import liquibase.statement.core.RenameColumnStatement; //导入依赖的package包/类
protected RenameColumnGeneratorHanaDBTest(SqlGenerator<RenameColumnStatement> generatorUnderTest) throws Exception {
    super(generatorUnderTest);
}
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:4,代码来源:RenameColumnGeneratorHanaDBTest.java


注:本文中的liquibase.statement.core.RenameColumnStatement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。