Class CreateTableColumn
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.sql.h2.H2SqlPart
com.northconcepts.datapipeline.sql.h2.CreateTableColumn
Generates a column definition for a CREATE TABLE statement for H2.
Sample Generated SQL:
email TEXT NOT NULL, CONSTRAINT "email_check" CHECK (email LIKE '%@%')
-
Constructor Summary
ConstructorsConstructorDescriptionCreateTableColumn(String columnName, TableColumnType type) Constructs a CreateTableColumn with the specified column name and type.CreateTableColumn(String columnName, TableColumnType type, Integer length) Constructs a CreateTableColumn with the specified column name, type, and length.CreateTableColumn(String columnName, TableColumnType type, Integer length, Integer scale) Constructs a CreateTableColumn with the specified column name, type, length, and scale. -
Method Summary
Modifier and TypeMethodDescriptionvoidcollectSqlFragment(CodeWriter writer) Writes this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.Returns the check constraint condition.Returns the check constraint name.Returns the column name.Returns the default value.Returns the column length.getScale()Returns the column scale.getType()Returns the column type.booleanReturns whether the column has auto-increment enabled.booleanReturns whether the column is nullable.booleanReturns whether the column is a primary key.booleanisUnique()Returns whether the column has a unique constraint.setAutoIncrement(boolean autoIncrement) Sets whether the column has auto-increment enabled.setCheckConstraint(String checkConstraintName, String condition) Sets the check constraint name and condition.setCheckConstraintCondition(String checkConstraintCondition) Sets the check constraint condition.setCheckConstraintName(String checkConstraintName) Sets the check constraint name.setColumnName(String columnName) Sets the column name.setDefaultValue(String defaultValue) Sets the default value.Sets the column length.setNullable(boolean nullable) Sets whether the column is nullable.setPretty(boolean pretty) Indicates ifSqlPart.getSqlFragment()adds line breaks and indentation instead of using one line (default is false).setPrimaryKey(boolean primaryKey) Sets whether the column is a primary key.Sets the column scale.setType(TableColumnType type) Sets the column type.setUnique(boolean unique) Sets whether the column has a unique constraint.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
-
CreateTableColumn
public CreateTableColumn() -
CreateTableColumn
Constructs a CreateTableColumn with the specified column name, type, length, and scale.- Parameters:
columnName- the column nametype- the column typelength- the column lengthscale- the column scale
-
CreateTableColumn
Constructs a CreateTableColumn with the specified column name, type, and length.- Parameters:
columnName- the column nametype- the column typelength- the column length
-
CreateTableColumn
Constructs a CreateTableColumn with the specified column name and type.- Parameters:
columnName- the column nametype- the column type
-
-
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
-
getColumnName
Returns the column name.- Returns:
- the column name
-
setColumnName
Sets the column name.- Parameters:
columnName- the column name- Returns:
- this instance
-
getType
Returns the column type.- Returns:
- the column type
-
setType
Sets the column type.- Parameters:
type- the column type- Returns:
- this instance
-
getLength
Returns the column length.- Returns:
- the column length
-
setLength
Sets the column length.- Parameters:
length- the column length- Returns:
- this instance
-
getScale
Returns the column scale.- Returns:
- the column scale
-
setScale
Sets the column scale.- Parameters:
scale- the column scale- Returns:
- this instance
-
isNullable
public boolean isNullable()Returns whether the column is nullable.- Returns:
- true if the column is nullable
-
setNullable
Sets whether the column is nullable.- Parameters:
nullable- true if the column is nullable- Returns:
- this instance
-
isUnique
public boolean isUnique()Returns whether the column has a unique constraint.- Returns:
- true if the column has a unique constraint
-
setUnique
Sets whether the column has a unique constraint.- Parameters:
unique- true if the column has a unique constraint- Returns:
- this instance
-
getDefaultValue
Returns the default value.- Returns:
- the default value
-
setDefaultValue
Sets the default value.- Parameters:
defaultValue- the default value- Returns:
- this instance
-
getCheckConstraintCondition
Returns the check constraint condition.- Returns:
- the check constraint condition
-
setCheckConstraintCondition
Sets the check constraint condition.- Parameters:
checkConstraintCondition- the check constraint condition- Returns:
- this instance
-
getCheckConstraintName
Returns the check constraint name.- Returns:
- the check constraint name
-
setCheckConstraintName
Sets the check constraint name.- Parameters:
checkConstraintName- the check constraint name- Returns:
- this instance
-
setCheckConstraint
Sets the check constraint name and condition.- Parameters:
checkConstraintName- the check constraint namecondition- the check constraint condition- Returns:
- this instance
-
isPrimaryKey
public boolean isPrimaryKey()Returns whether the column is a primary key.- Returns:
- true if the column is a primary key
-
setPrimaryKey
Sets whether the column is a primary key.- Parameters:
primaryKey- true if the column is a primary key- Returns:
- this instance
-
isAutoIncrement
public boolean isAutoIncrement()Returns whether the column has auto-increment enabled.- Returns:
- true if the column has auto-increment enabled
-
setAutoIncrement
Sets whether the column has auto-increment enabled.- Parameters:
autoIncrement- true if the column has auto-increment enabled- Returns:
- this instance
-