• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CreateIndexStatement类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: generateStatements

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
public SqlStatement[] generateStatements(Database database) {
    List<String> columns = new ArrayList<String>();
    for (ColumnConfig column : getColumns()) {
        columns.add(column.getName());
    }

 return new SqlStatement[]{
   new CreateIndexStatement(
	    getIndexName(),
	    getSchemaName() == null ? database.getDefaultSchemaName() : getSchemaName(),
	    getTableName(),
	    this.isUnique(),
	    getAssociatedWith(),
	    columns.toArray(new String[getColumns().size()]))
	    .setTablespace(getTablespace())
 };
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:18,代码来源:CreateIndexChange.java


示例2: generateSql

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

	if (statement instanceof CreateIndexWithWhereStatement) {
		if (superSql.length != 1) {
			LogFactory.getLogger().warning("expected 1 create index statement, but got " + superSql.length);
        	return superSql;
		}
		
		return new Sql[] {
				new UnparsedSql(superSql[0].toSql() + " WHERE " + ((CreateIndexWithWhereStatement)statement).getWhere(),
						superSql[0].getEndDelimiter(), superSql[0].getAffectedDatabaseObjects().toArray(new DatabaseObject[0]))
		};
	} else {
		return superSql;
	}
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:CreateIndexWithWhereGenerator.java


示例3: generateStatements

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Override
public SqlStatement[] generateStatements(Database database) {
  SqlStatement[] statements = super.generateStatements(database);
  if (!MSSQLDatabase.PRODUCT_NAME.equals(database.getDatabaseProductName())) {
  	return statements;
  }

  List<SqlStatement> extendedStatements = new ArrayList<SqlStatement>(statements.length);
  for (SqlStatement statement : statements) {
    if (statement instanceof CreateIndexStatement) {
      extendedStatements.add(new CreateIndexStatementMSSQL((CreateIndexStatement)statement, includedColumns, fillFactor));
    } else {
      extendedStatements.add(statement);
    }
  }

  return extendedStatements.toArray(new SqlStatement[0]);
}
 
开发者ID:sabomichal,项目名称:liquibase-mssql,代码行数:19,代码来源:CreateIndexChangeMSSQL.java


示例4: integrates

import liquibase.statement.core.CreateIndexStatement; //导入依赖的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


示例5: testUpdateSQL

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Test
public void testUpdateSQL() {
    enableLogging();

    SqlStatement[] statements = generateStatements();
    Assert.assertEquals(3, statements.length);
    Assert.assertEquals(CommentStatement.class, statements[0].getClass());
    Assert.assertEquals("pt-online-schema-change --alter=\"ADD UNIQUE INDEX theIndexName (indexedColumn)\" "
            + "--alter-foreign-keys-method=auto "
            + "--host=localhost --port=3306 --user=user --password=*** --execute D=testdb,t=person",
            ((CommentStatement)statements[0]).getText());
    Assert.assertEquals(CommentStatement.class, statements[1].getClass());
    Assert.assertEquals(CreateIndexStatement.class, statements[2].getClass());
}
 
开发者ID:adangel,项目名称:liquibase-percona,代码行数:15,代码来源:PerconaCreateIndexChangeTest.java


示例6: generateStatements

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Override
public SqlStatement[] generateStatements(final Database database) {
	final SqlStatement[] superStatements = super.generateStatements(database);
	if (m_where == null) return superStatements;
	
	if (superStatements.length != 1) {
		LogFactory.getLogger().warning("expected 1 create index statement, but got " + superStatements.length);
		return superStatements;
	}
	
    return new SqlStatement[]{
    		new CreateIndexWithWhereStatement((CreateIndexStatement)superStatements[0], m_where)
    };
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:CreateIndexWithWhereChange.java


示例7: generateSql

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Override
public Sql[] generateSql(CreateIndexStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
  if (statement instanceof CreateIndexStatementMSSQL) {
    return generateMSSQLSql((CreateIndexStatementMSSQL)statement, database, sqlGeneratorChain);
  }

  return super.generateSql(statement, database, sqlGeneratorChain);
}
 
开发者ID:sabomichal,项目名称:liquibase-mssql,代码行数:9,代码来源:CreateIndexGeneratorMSSQL.java


示例8: CreateIndexStatementMSSQL

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
public CreateIndexStatementMSSQL(CreateIndexStatement createIndexStatement, String includedColumns, Integer fillFactor) {
  super(createIndexStatement.getIndexName(), createIndexStatement.getTableCatalogName(),
      createIndexStatement.getTableSchemaName(), createIndexStatement.getTableName(),
      createIndexStatement.isUnique(), createIndexStatement.getAssociatedWith(),
      createIndexStatement.getColumns());
  
  if (createIndexStatement.isClustered() != null) {
  	setClustered(createIndexStatement.isClustered());
  }

  this.includedColumns = includedColumns;
  this.fillFactor = fillFactor;
}
 
开发者ID:sabomichal,项目名称:liquibase-mssql,代码行数:14,代码来源:CreateIndexStatementMSSQL.java


示例9: generateSql

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
/**
 * @see liquibase.sqlgenerator.core.CreateIndexGenerator#generateSql(liquibase.statement.core.CreateIndexStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain)
 */
@Override
public Sql[] generateSql(CreateIndexStatement statement, Database database, SqlGeneratorChain sqlGeneratorChain) {
	StringBuffer buffer = new StringBuffer();

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

	if (statement.getIndexName() != null) {
		//String indexSchema = statement.getTableSchemaName();
		buffer.append(database.escapeObjectName(statement.getIndexName(), Index.class)).append(" ");
	}

	buffer.append("(");
	Iterator<AddColumnConfig> iterator = Arrays.asList(statement.getColumns()).iterator();
	while (iterator.hasNext()) {
		AddColumnConfig column = iterator.next();
		buffer.append(database.escapeColumnName(statement.getTableCatalogName(), statement.getTableSchemaName(), statement.getTableName(), column.getName()));
		if (iterator.hasNext()) {
			buffer.append(", ");
		}
	}
	buffer.append(")");

	buffer.append("ON ");
	buffer.append(database.escapeTableName(statement.getTableCatalogName(), statement.getTableSchemaName(), statement.getTableName()));

	return new Sql[]{new UnparsedSql(buffer.toString())};
}
 
开发者ID:liquibase,项目名称:liquibase-teradata,代码行数:35,代码来源:CreateIndexGeneratorTeradata.java


示例10: testCreateSingleColumnUniqueIndex

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Test
public void testCreateSingleColumnUniqueIndex() throws Exception {
    super.isValid();
    CreateIndexStatement createIndexStatement =
            new CreateIndexStatement("index_name", null, null, "table_name", true, null, (AddColumnConfig) new AddColumnConfig().setName("column_name"));

    Database hanadb = new HanaDBDatabase();
    SqlGeneratorChain sqlGeneratorChain = new MockSqlGeneratorChain();

    assertFalse(generatorUnderTest.validate(createIndexStatement, hanadb, new MockSqlGeneratorChain()).hasErrors());
    Sql[] generatedSql = generatorUnderTest.generateSql(createIndexStatement, hanadb, sqlGeneratorChain);
    assertTrue(generatedSql.length == 1);
    assertEquals("CREATE UNIQUE INDEX \"index_name\" ON \"table_name\" (\"column_name\")", generatedSql[0].toSql());

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


示例11: testCreateMultiColumnNonUniqueIndex

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Test
public void testCreateMultiColumnNonUniqueIndex() throws Exception {
    super.isValid();
    CreateIndexStatement createIndexStatement =
            new CreateIndexStatement("index_name", null, null, "table_name", null, null, (AddColumnConfig) new AddColumnConfig().setName("column_name_1"), (AddColumnConfig) new AddColumnConfig().setName("column_name_2"));

    Database hanadb = new HanaDBDatabase();
    SqlGeneratorChain sqlGeneratorChain = new MockSqlGeneratorChain();

    assertFalse(generatorUnderTest.validate(createIndexStatement, hanadb, new MockSqlGeneratorChain()).hasErrors());
    Sql[] generatedSql = generatorUnderTest.generateSql(createIndexStatement, hanadb, sqlGeneratorChain);
    assertTrue(generatedSql.length == 1);
    assertEquals("CREATE INDEX \"index_name\" ON \"table_name\" (\"column_name_1\", \"column_name_2\")", generatedSql[0].toSql());

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


示例12: validate

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
public ValidationErrors validate(CreateIndexStatement createIndexStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    ValidationErrors validationErrors = new ValidationErrors();
    validationErrors.checkRequiredField("tableName", createIndexStatement.getTableName());
    validationErrors.checkRequiredField("columns", createIndexStatement.getColumns());
    return validationErrors;
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:7,代码来源:CreateIndexGenerator.java


示例13: supports

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


示例14: generateSql

import liquibase.statement.core.CreateIndexStatement; //导入依赖的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


示例15: CreateIndexWithWhereStatement

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
public CreateIndexWithWhereStatement(final CreateIndexStatement statement, final String where) {
	this(statement.getIndexName(), statement.getTableSchemaName(), statement.getTableName(), statement.isUnique(), statement.getAssociatedWith(), statement.getColumns());
	m_where = where;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:5,代码来源:CreateIndexWithWhereStatement.java


示例16: supports

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


示例17: supports

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


示例18: generateSql

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

        // 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(database.escapeIndexName(statement.getTableCatalogName(), indexSchema, statement.getIndexName())).append(" ");
	    }
	    buffer.append("ON ");
	    buffer.append(database.escapeTableName(statement.getTableCatalogName(), statement.getTableSchemaName(), statement.getTableName())).append(" (");
	    Iterator<AddColumnConfig> iterator = Arrays.asList(statement.getColumns()).iterator();
	    while (iterator.hasNext()) {
		    AddColumnConfig column = iterator.next();
		    buffer.append(database.escapeColumnName(statement.getTableCatalogName(), statement.getTableSchemaName(), statement.getTableName(), column.getName()));
		    if (iterator.hasNext()) {
			    buffer.append(", ");
		    }
	    }
	    buffer.append(")");

//	    return new Sql[]{new UnparsedSql(buffer.toString())};
        return new Sql[]{new UnparsedSql(buffer.toString(), getAffectedIndex(statement))};
    }
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:44,代码来源:CreateIndexGeneratorHanaDB.java


示例19: CreateIndexGeneratorHanaDBTest

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


示例20: createSampleSqlStatement

import liquibase.statement.core.CreateIndexStatement; //导入依赖的package包/类
@Override
protected CreateIndexStatement createSampleSqlStatement() {
       CreateIndexStatement createIndexStatement =
               new CreateIndexStatement("index_name", null, null, "table_name", true, null, (AddColumnConfig) new AddColumnConfig().setName("column_name"));
       return createIndexStatement;
   }
 
开发者ID:lbitonti,项目名称:liquibase-hana,代码行数:7,代码来源:CreateIndexGeneratorHanaDBTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NetworkChannel类代码示例发布时间:2022-05-22
下一篇:
Java FloatingIP类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap