Class CreateIndex
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.sql.h2.H2SqlPart
com.northconcepts.datapipeline.sql.h2.CreateIndex
Generates a CREATE INDEX statement for H2.
Sample Generated SQL:
CREATE UNIQUE INDEX idx_firstname_lastname ON person (firstname, lastname);
-
Constructor Summary
ConstructorsConstructorDescriptionCreateIndex(String indexName, String tableName, String... columnNames) Constructs a CreateIndex with the specified index name, table name, and column names. -
Method Summary
Modifier and TypeMethodDescriptionvoidcollectSqlFragment(CodeWriter writer) Writes this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.Returns the column names.Returns the index name.Returns the table name.booleanisUnique()Returns whether this is a unique index.setColumnNames(String... columnNames) Sets the column names.setColumnNames(List<String> columnNames) Sets the column names.setIndexName(String indexName) Sets the index name.setPretty(boolean pretty) Indicates ifSqlPart.getSqlFragment()adds line breaks and indentation instead of using one line (default is false).setTableName(String tableName) Sets the table name.setUnique(boolean unique) Sets whether this is a unique index.Methods inherited from class com.northconcepts.datapipeline.sql.h2.H2SqlPart
escapeKeyword, placeBackTicksMethods inherited from class com.northconcepts.datapipeline.jdbc.sql.SqlPart
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
-
Constructor Details
-
CreateIndex
public CreateIndex() -
CreateIndex
Constructs a CreateIndex with the specified index name, table name, and column names.- Parameters:
indexName- the index nametableName- the table namecolumnNames- the column names to index
-
-
Method Details
-
setPretty
Description copied from class:SqlPartIndicates ifSqlPart.getSqlFragment()adds line breaks and indentation instead of using one line (default is false). -
collectSqlFragment
Description copied from class:SqlPartWrites this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.- Specified by:
collectSqlFragmentin classSqlPart
-
getIndexName
Returns the index name.- Returns:
- the index name
-
setIndexName
Sets the index name.- Parameters:
indexName- the index name- Returns:
- this instance
-
getTableName
Returns the table name.- Returns:
- the table name
-
setTableName
Sets the table name.- Parameters:
tableName- the table name- Returns:
- this instance
-
getColumnNames
Returns the column names.- Returns:
- the column names
-
setColumnNames
Sets the column names.- Parameters:
columnNames- the column names- Returns:
- this instance
-
setColumnNames
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
Sets whether this is a unique index.- Parameters:
unique- true for a unique index- Returns:
- this instance
-