當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。