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

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

java 1次浏览

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

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

示例1: generateStatements

点赞 3

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
/**
 * Generates one or more statements depending on how the SQL should be parsed.
 * If split statements is set to true then the SQL is split on the ; and go\n entries
 * found in the sql text and each is made a separate statement.
 *
 * If stripping comments is true then any comments after -- on a line and any comments
 * between /* and \*\/ will be stripped before the splitting is executed.
 *
 * The end result is one or more SQL statements split in the way the user requested
 */
public SqlStatement[] generateStatements(Database database) {

    List<SqlStatement> returnStatements = new ArrayList<SqlStatement>();

    if (StringUtils.trimToNull(getSql()) == null) {
        return new SqlStatement[0];
    }

    String processedSQL = getSql().replaceAll("\r\n", "\n").replaceAll("\r", "\n");
    for (String statement : StringUtils.processMutliLineSQL(processedSQL, isStrippingComments(), isSplittingStatements(), getEndDelimiter())) {
        if (database instanceof MSSQLDatabase) {
             statement = statement.replaceAll("\n", "\r\n");
         }

        returnStatements.add(new RawSqlStatement(statement, getEndDelimiter()));
    }

    return returnStatements.toArray(new SqlStatement[returnStatements.size()]);
}
 

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

示例2: integrates

点赞 3

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Test
public void integrates() {
    final AddColumnConfig firstColumnConfig = new AddColumnConfig();
    firstColumnConfig.setName("id");
    final AddColumnConfig secondColumnConfig = new AddColumnConfig();
    secondColumnConfig.setName("name");

    CreateIndexStatement statement = new CreateIndexStatement(null, null, null, "TABLE_NAME", true, null, firstColumnConfig, secondColumnConfig);
    Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals("CREATE UNIQUE INDEX ON [TABLE_NAME]([id], [name])", sql[0].toSql());

    statement = new CreateIndexStatementMSSQL(statement, "included, includedtoo", null);
    sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals("CREATE UNIQUE INDEX ON [TABLE_NAME]([id], [name]) INCLUDE ([included], [includedtoo])", sql[0].toSql());

    statement = new CreateIndexStatementMSSQL(statement, null, 50);
    sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals("CREATE UNIQUE INDEX ON [TABLE_NAME]([id], [name]) WITH (FILLFACTOR = 50)", sql[0].toSql());

    statement = new CreateIndexStatementMSSQL(statement, "included, includedtoo", 50);
    sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals("CREATE UNIQUE INDEX ON [TABLE_NAME]([id], [name]) INCLUDE ([included], [includedtoo]) WITH (FILLFACTOR = 50)", sql[0].toSql());
}
 

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:24,
代码来源:IndexGeneratorTest.java

示例3: integrates

点赞 3

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Test
public void integrates() {
  AddPrimaryKeyStatement statement = new AddPrimaryKeyStatement("myCat", "mySchema", "myTable", "myCol", "myConstraint");
  statement.setClustered(true);

  Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
  assertEquals("ALTER TABLE [mySchema].[myTable] ADD CONSTRAINT [myConstraint] PRIMARY KEY ([myCol])", sql[0].toSql());

  statement = new AddPrimaryKeyStatementMSSQL(statement, null);
  sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
  assertEquals("ALTER TABLE [mySchema].[myTable] ADD CONSTRAINT [myConstraint] PRIMARY KEY ([myCol])", sql[0].toSql());

  statement = new AddPrimaryKeyStatementMSSQL(statement, 50);
  sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
  assertEquals("ALTER TABLE [mySchema].[myTable] ADD CONSTRAINT [myConstraint] PRIMARY KEY ([myCol]) WITH (FILLFACTOR = 50)", sql[0].toSql());
}
 

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:17,
代码来源:PrimaryKeyGeneratorTest.java

示例4: generateSql

点赞 3

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
/**
 * @see liquibase.sqlgenerator.core.DropIndexGenerator#generateSql(liquibase.statement.core.DropIndexStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
 */
@Override
public Sql[] generateSql(DropIndexStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
	List<String> associatedWith = StringUtils.splitAndTrim(statement.getAssociatedWith(), ",");
	if (associatedWith != null) {
		if (associatedWith.contains(Index.MARK_PRIMARY_KEY)|| associatedWith.contains(Index.MARK_UNIQUE_CONSTRAINT)) {
			return new Sql[0];
		} else if (associatedWith.contains(Index.MARK_FOREIGN_KEY) ) {
			if (!(database instanceof OracleDatabase || database instanceof MSSQLDatabase)) {
				return new Sql[0];
			}
		}
	}

	String schemaName = statement.getTableSchemaName();

	return new Sql[] {new UnparsedSql("DROP INDEX " + database.escapeObjectName(statement.getIndexName(), Index.class) +" ON " + database.escapeTableName(statement.getTableCatalogName(), schemaName, statement.getTableName()) ) };
}
 

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

示例5: suppressSqlStatement

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
private void suppressSqlStatement(final SqlStatement sql, final List<SqlVisitor> sqlVisitors) throws DatabaseException
{
	if (SqlGeneratorFactory.getInstance().generateStatementsVolatile(sql, database))
	{
		throw new DatabaseException(sql.getClass().getSimpleName() + " requires access to up to date database metadata which is not available when you suppress SQL execution");
	}

	for (String statement : applyVisitors(sql, sqlVisitors))
	{
		if (statement == null)
		{
			continue;
		}

		if (database instanceof MSSQLDatabase || database instanceof SybaseDatabase || database instanceof SybaseASADatabase)
		{
			comment("Suppressed: " + statement);
			comment("Suppressed: GO");
		}
		else
		{
			final String endDelimiter = sql instanceof RawSqlStatement ? ((RawSqlStatement) sql).getEndDelimiter() : ";";

			if (!statement.endsWith(endDelimiter))
			{
				statement += endDelimiter;
			}
			comment("Suppressed: " + statement);
		}
	}
}
 

开发者ID:Jurrie,
项目名称:liquibase-suppress-output,
代码行数:32,
代码来源:SuppressOutputExecutor.java

示例6: toDatabaseDataType

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Override
public DatabaseDataType toDatabaseDataType(Database database) {
   if (database instanceof DB2Database || database instanceof FirebirdDatabase) {
        return new DatabaseDataType("SMALLINT");
    } else if (database instanceof MSSQLDatabase) {
        return new DatabaseDataType("BIT");
    } else if (database instanceof MySQLDatabase) {
        if (originalDefinition.toLowerCase().startsWith("bit")) {
            return new DatabaseDataType("BIT", getParameters());
        }
        return new DatabaseDataType("BIT", 1);
    } else if (database instanceof OracleDatabase) {
        return new DatabaseDataType("NUMBER", 1);
    } else if (database instanceof SybaseASADatabase || database instanceof SybaseDatabase) {
        return new DatabaseDataType("BIT");
    } else if (database instanceof DerbyDatabase) {
        if (((DerbyDatabase) database).supportsBooleanDataType()) {
            return new DatabaseDataType("BOOLEAN");
        } else {
            return new DatabaseDataType("SMALLINT");
        }
    } else if (database instanceof SQLFireDatabase) {
    	return new DatabaseDataType("SMALLINT");
    } else if (database instanceof HsqlDatabase) {
        return new DatabaseDataType("BOOLEAN");
    }

    return super.toDatabaseDataType(database);
}
 

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

示例7: isNumericBoolean

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
protected boolean isNumericBoolean(Database database) {
    if (database instanceof DerbyDatabase) {
        return !((DerbyDatabase) database).supportsBooleanDataType();
    }
    return database instanceof DB2Database
            || database instanceof FirebirdDatabase
            || database instanceof MSSQLDatabase
            || database instanceof MySQLDatabase
            || database instanceof OracleDatabase
            || database instanceof SQLFireDatabase
            || database instanceof SQLiteDatabase
            || database instanceof SybaseASADatabase
            || database instanceof SybaseDatabase;
}
 

开发者ID:liquibase,
项目名称:liquibase-sqlfire,
代码行数:15,
代码来源:BooleanType.java

示例8: generateSql

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Override
public Sql[] generateSql(AddDefaultValueStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    Object defaultValue = statement.getDefaultValue();
    return new Sql[] {
            new UnparsedSql("ALTER TABLE " + database.escapeTableName(statement.getSchemaName(), statement.getTableName()) + " ADD CONSTRAINT " + ((MSSQLDatabase) database).generateDefaultConstraintName(statement.getTableName(), statement.getColumnName()) + " DEFAULT " + TypeConverterFactory.getInstance().findTypeConverter(database).getDataType(defaultValue).convertObjectToString(defaultValue, database) + " FOR " + statement.getColumnName(),
                    new Column()
                    .setTable(new Table(statement.getTableName()).setSchema(statement.getSchemaName()))
                    .setName(statement.getColumnName()))
    };
}
 

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

示例9: supports

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Override
public boolean supports(AddAutoIncrementStatement statement, Database database) {
    return (database.supportsAutoIncrement()
            && !(database instanceof DerbyDatabase)
            && !(database instanceof MSSQLDatabase)
            && !(database instanceof HsqlDatabase)
            && !(database instanceof H2Database));
}
 

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

示例10: supports

点赞 2

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

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

示例11: outputStatement

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
private void outputStatement(SqlStatement sql, List<SqlVisitor> sqlVisitors) throws DatabaseException {
    try {
        if (SqlGeneratorFactory.getInstance().requiresCurrentDatabaseMetadata(sql, database)) {
            throw new DatabaseException(sql.getClass().getSimpleName()+" requires access to up to date database metadata which is not available in SQL output mode");
        }
        for (String statement : applyVisitors(sql, sqlVisitors)) {
            if (statement == null) {
                continue;
            }
            output.write(statement);


            if (database instanceof MSSQLDatabase || database instanceof SybaseDatabase || database instanceof SybaseASADatabase) {
                output.write(StreamUtil.getLineSeparator());
                output.write("GO");
//            } else if (database instanceof OracleDatabase) {
//                output.write(StreamUtil.getLineSeparator());
//                output.write("/");
            } else {
                String endDelimiter = ";";
                if (sql instanceof RawSqlStatement) {
                    endDelimiter = ((RawSqlStatement) sql).getEndDelimiter();
                }
                if (!statement.endsWith(endDelimiter)) {
                    output.write(endDelimiter);
                }
            }
            output.write(StreamUtil.getLineSeparator());
            output.write(StreamUtil.getLineSeparator());
        }
    } catch (IOException e) {
        throw new DatabaseException(e);
    }
}
 

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

示例12: integrates

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
@Test
public void integrates() {
    InsertStatement statement = new InsertStatement(null, null, "TABLE_NAME");
    statement.addColumnValue("id", 1);
    statement.addColumnValue("name", "asdf");
    
    statement = new InsertStatementMSSQL(statement, true);

    Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
    assertEquals(3, sql.length);

    for (Sql currentSql : sql) {
        assertSqlHasNoDanglingTokens(currentSql.toSql());
    }
}
 

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:16,
代码来源:InsertGeneratorTest.java

示例13: supports

点赞 2

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

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

示例14: generateSql

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
public Sql[] generateSql(AddForeignKeyConstraintStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
 StringBuilder sb = new StringBuilder();
 sb.append("ALTER TABLE ")
   .append(database.escapeTableName(statement.getBaseTableSchemaName(), statement.getBaseTableName()))
   .append(" ADD CONSTRAINT ");
 if (!(database instanceof InformixDatabase)) {
  sb.append(database.escapeConstraintName(statement.getConstraintName()));
 }
 sb.append(" FOREIGN KEY (")
   .append(database.escapeColumnNameList(statement.getBaseColumnNames()))
   .append(") REFERENCES ")
   .append(database.escapeTableName(statement.getReferencedTableSchemaName(), statement.getReferencedTableName()))
   .append(" (")
   .append(database.escapeColumnNameList(statement.getReferencedColumnNames()))
   .append(")");

 if (statement.getOnUpdate() != null) {
  if (database instanceof OracleDatabase) {
   //don't use
  } else if (database instanceof InformixDatabase) {
   //TODO don't know if correct
  } else {
   sb.append(" ON UPDATE ").append(statement.getOnUpdate());
  }
 }

 if (statement.getOnDelete() != null) {
        if ((database instanceof OracleDatabase) && (statement.getOnDelete().equalsIgnoreCase("RESTRICT") || statement.getOnDelete().equalsIgnoreCase("NO ACTION"))) {
            //don't use
        } else if ((database instanceof MSSQLDatabase) && statement.getOnDelete().equalsIgnoreCase("RESTRICT")) {
            //don't use                        
  } else if (database instanceof InformixDatabase && !(statement.getOnDelete().equalsIgnoreCase("CASCADE"))) {
   //TODO Informix can handle ON DELETE CASCADE only, but I don't know if this is really correct
  	// see "REFERENCES Clause" in manual
  } else {
   sb.append(" ON DELETE ").append(statement.getOnDelete());
  }
 }

    if (statement.isDeferrable() || statement.isInitiallyDeferred()) {
        if (statement.isDeferrable()) {
            sb.append(" DEFERRABLE");
        }

        if (statement.isInitiallyDeferred()) {
            sb.append(" INITIALLY DEFERRED");
        }
    }

 if (database instanceof InformixDatabase) {
  sb.append(" CONSTRAINT ");
  sb.append(database.escapeConstraintName(statement.getConstraintName()));
 }

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

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

示例15: supports

点赞 2

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

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

示例16: generateSql

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
public Sql[] generateSql(CreateIndexStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {

        // Default filter of index creation:
        // creation of all indexes with associations are switched off.
        List<String> associatedWith = StringUtils.splitAndTrim(statement.getAssociatedWith(), ",");
        if (associatedWith != null && (associatedWith.contains(Index.MARK_PRIMARY_KEY) ||
            associatedWith.contains(Index.MARK_UNIQUE_CONSTRAINT) ||
            associatedWith.contains(Index.MARK_FOREIGN_KEY))) {
            return new Sql[0];
        }

	    StringBuilder buffer = new StringBuilder();

	    buffer.append("CREATE ");
	    if (statement.isUnique() != null && statement.isUnique()) {
		    buffer.append("UNIQUE ");
	    }
	    buffer.append("INDEX ");

	    if (statement.getIndexName() != null) {
            String indexSchema = statement.getTableSchemaName();
            buffer.append(database.escapeIndexName(null, statement.getIndexName())).append(" ");
	    }
	    buffer.append("ON ");
	    buffer.append(database.escapeTableName(statement.getTableSchemaName(), statement.getTableName())).append("(");
	    Iterator<String> iterator = Arrays.asList(statement.getColumns()).iterator();
	    while (iterator.hasNext()) {
		    String column = iterator.next();
		    buffer.append(database.escapeColumnName(statement.getTableSchemaName(), statement.getTableName(), column));
		    if (iterator.hasNext()) {
			    buffer.append(", ");
		    }
	    }
	    buffer.append(")");

	    if (StringUtils.trimToNull(statement.getTablespace()) != null && database.supportsTablespaces()) {
		    if (database instanceof MSSQLDatabase || database instanceof SybaseASADatabase) {
			    buffer.append(" ON ").append(statement.getTablespace());
		    } else if (database instanceof DB2Database || database instanceof InformixDatabase) {
			    buffer.append(" IN ").append(statement.getTablespace());
		    } else {
			    buffer.append(" TABLESPACE ").append(statement.getTablespace());
		    }
	    }

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

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

示例17: supports

点赞 2

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

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

示例18: supports

点赞 2

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

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

示例19: supports

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
public boolean supports(Database database) {
    return database instanceof MSSQLDatabase;
}
 

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

示例20: generateStatements

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
    List<SqlStatement> statements = new ArrayList<SqlStatement>();

    String newTableSchemaName = getNewTableSchemaName() == null?database.getDefaultSchemaName():getNewTableSchemaName();
    String existingTableSchemaName = getExistingTableSchemaName() == null?database.getDefaultSchemaName():getExistingTableSchemaName();

    SqlStatement[] createTablesSQL = {new RawSqlStatement("CREATE TABLE " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " AS SELECT DISTINCT " + getExistingColumnName() + " AS " + getNewColumnName() + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + " WHERE " + getExistingColumnName() + " IS NOT NULL")};
    if (database instanceof MSSQLDatabase) {
        createTablesSQL = new SqlStatement[]{new RawSqlStatement("SELECT DISTINCT " + getExistingColumnName() + " AS " + getNewColumnName() + " INTO " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + " WHERE " + getExistingColumnName() + " IS NOT NULL"),};
    } else if (database instanceof SybaseASADatabase) {
        createTablesSQL = new SqlStatement[]{new RawSqlStatement("SELECT DISTINCT " + getExistingColumnName() + " AS " + getNewColumnName() + " INTO " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + " WHERE " + getExistingColumnName() + " IS NOT NULL"),};
    } else if (database instanceof DB2Database) {
        createTablesSQL = new SqlStatement[]{
                new RawSqlStatement("CREATE TABLE " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " AS (SELECT " + getExistingColumnName() + " AS " + getNewColumnName() + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + ") WITH NO DATA"),
                new RawSqlStatement("INSERT INTO " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " SELECT DISTINCT " + getExistingColumnName() + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + " WHERE " + getExistingColumnName() + " IS NOT NULL"),
        };
    } else if (database instanceof InformixDatabase) {
        createTablesSQL = new SqlStatement[] {
                new RawSqlStatement("CREATE TABLE " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " ( "  + getNewColumnName() + " " + getNewColumnDataType() + " )"),
                new RawSqlStatement("INSERT INTO " + database.escapeTableName(newTableSchemaName, getNewTableName()) + " ( "  + getNewColumnName() + " ) SELECT DISTINCT "  + getExistingColumnName() + " FROM " + database.escapeTableName(existingTableSchemaName, getExistingTableName()) + " WHERE " + getExistingColumnName() + " IS NOT NULL"),
        };
    }

    statements.addAll(Arrays.asList(createTablesSQL));

    if (!(database instanceof OracleDatabase)) {
        AddNotNullConstraintChange addNotNullChange = new AddNotNullConstraintChange();
        addNotNullChange.setSchemaName(newTableSchemaName);
        addNotNullChange.setTableName(getNewTableName());
        addNotNullChange.setColumnName(getNewColumnName());
        addNotNullChange.setColumnDataType(getNewColumnDataType());
        statements.addAll(Arrays.asList(addNotNullChange.generateStatements(database)));
    }

    if (database instanceof DB2Database) {
        statements.add(new ReorganizeTableStatement(newTableSchemaName, getNewTableName()));
    }

    AddPrimaryKeyChange addPKChange = new AddPrimaryKeyChange();
    addPKChange.setSchemaName(newTableSchemaName);
    addPKChange.setTableName(getNewTableName());
    addPKChange.setColumnNames(getNewColumnName());
    statements.addAll(Arrays.asList(addPKChange.generateStatements(database)));

    if (database instanceof DB2Database) {
        statements.add(new ReorganizeTableStatement(newTableSchemaName, getNewTableName()));
    }

    AddForeignKeyConstraintChange addFKChange = new AddForeignKeyConstraintChange();
    addFKChange.setBaseTableSchemaName(existingTableSchemaName);
    addFKChange.setBaseTableName(getExistingTableName());
    addFKChange.setBaseColumnNames(getExistingColumnName());
    addFKChange.setReferencedTableSchemaName(newTableSchemaName);
    addFKChange.setReferencedTableName(getNewTableName());
    addFKChange.setReferencedColumnNames(getNewColumnName());

    addFKChange.setConstraintName(getFinalConstraintName());
    statements.addAll(Arrays.asList(addFKChange.generateStatements(database)));

    return statements.toArray(new SqlStatement[statements.size()]);
}
 

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

示例21: supportsReplaceIfExistsOption

点赞 2

import liquibase.database.core.MSSQLDatabase; //导入依赖的package包/类
private boolean supportsReplaceIfExistsOption(Database database) {
	return !(database instanceof SQLiteDatabase
	    || database instanceof MSSQLDatabase);
}
 

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

示例22: supports

点赞 2

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

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:4,
代码来源:InsertGenerator.java

示例23: supports

点赞 2

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

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:4,
代码来源:InsertSetGenerator.java

示例24: supports

点赞 2

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

开发者ID:sabomichal,
项目名称:liquibase-mssql,
代码行数:6,
代码来源:DropStoredProcedureGeneratorMSSQL.java


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