Class CreateIndex


public class CreateIndex extends H2SqlPart

Generates a CREATE INDEX statement for H2.


Sample Generated SQL:

CREATE UNIQUE INDEX idx_firstname_lastname ON person (firstname, lastname);
  • Constructor Details

    • CreateIndex

      public CreateIndex()
    • CreateIndex

      public CreateIndex(String indexName, String tableName, String... columnNames)
      Constructs a CreateIndex with the specified index name, table name, and column names.
      Parameters:
      indexName - the index name
      tableName - the table name
      columnNames - the column names to index
  • Method Details

    • setPretty

      public CreateIndex setPretty(boolean pretty)
      Description copied from class: SqlPart
      Indicates if SqlPart.getSqlFragment() adds line breaks and indentation instead of using one line (default is false).
      Overrides:
      setPretty in class SqlPart
    • collectSqlFragment

      public void collectSqlFragment(CodeWriter writer)
      Description copied from class: SqlPart
      Writes this part's SQL to the writer; used by SqlPart.getSqlFragment() and by enclosing parts.
      Specified by:
      collectSqlFragment in class SqlPart
    • getIndexName

      public String getIndexName()
      Returns the index name.
      Returns:
      the index name
    • setIndexName

      public CreateIndex setIndexName(String indexName)
      Sets the index name.
      Parameters:
      indexName - the index name
      Returns:
      this instance
    • getTableName

      public String getTableName()
      Returns the table name.
      Returns:
      the table name
    • setTableName

      public CreateIndex setTableName(String tableName)
      Sets the table name.
      Parameters:
      tableName - the table name
      Returns:
      this instance
    • getColumnNames

      public List<String> getColumnNames()
      Returns the column names.
      Returns:
      the column names
    • setColumnNames

      public CreateIndex setColumnNames(List<String> columnNames)
      Sets the column names.
      Parameters:
      columnNames - the column names
      Returns:
      this instance
    • setColumnNames

      public CreateIndex setColumnNames(String... columnNames)
      Sets the column names.
      Parameters:
      columnNames - the column names
      Returns:
      this instance
    • isUnique

      public boolean isUnique()
      Returns whether this is a unique index.
      Returns:
      true if this is a unique index
    • setUnique

      public CreateIndex setUnique(boolean unique)
      Sets whether this is a unique index.
      Parameters:
      unique - true for a unique index
      Returns:
      this instance