Class CreateTableColumn


public class CreateTableColumn extends H2SqlPart

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 Details

    • CreateTableColumn

      public CreateTableColumn()
    • CreateTableColumn

      public CreateTableColumn(String columnName, TableColumnType type, Integer length, Integer scale)
      Constructs a CreateTableColumn with the specified column name, type, length, and scale.
      Parameters:
      columnName - the column name
      type - the column type
      length - the column length
      scale - the column scale
    • CreateTableColumn

      public CreateTableColumn(String columnName, TableColumnType type, Integer length)
      Constructs a CreateTableColumn with the specified column name, type, and length.
      Parameters:
      columnName - the column name
      type - the column type
      length - the column length
    • CreateTableColumn

      public CreateTableColumn(String columnName, TableColumnType type)
      Constructs a CreateTableColumn with the specified column name and type.
      Parameters:
      columnName - the column name
      type - the column type
  • Method Details

    • setPretty

      public CreateTableColumn 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
    • getColumnName

      public String getColumnName()
      Returns the column name.
      Returns:
      the column name
    • setColumnName

      public CreateTableColumn setColumnName(String columnName)
      Sets the column name.
      Parameters:
      columnName - the column name
      Returns:
      this instance
    • getType

      public TableColumnType getType()
      Returns the column type.
      Returns:
      the column type
    • setType

      public CreateTableColumn setType(TableColumnType type)
      Sets the column type.
      Parameters:
      type - the column type
      Returns:
      this instance
    • getLength

      public Integer getLength()
      Returns the column length.
      Returns:
      the column length
    • setLength

      public CreateTableColumn setLength(Integer length)
      Sets the column length.
      Parameters:
      length - the column length
      Returns:
      this instance
    • getScale

      public Integer getScale()
      Returns the column scale.
      Returns:
      the column scale
    • setScale

      public CreateTableColumn setScale(Integer scale)
      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

      public CreateTableColumn setNullable(boolean nullable)
      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

      public CreateTableColumn setUnique(boolean unique)
      Sets whether the column has a unique constraint.
      Parameters:
      unique - true if the column has a unique constraint
      Returns:
      this instance
    • getDefaultValue

      public String getDefaultValue()
      Returns the default value.
      Returns:
      the default value
    • setDefaultValue

      public CreateTableColumn setDefaultValue(String defaultValue)
      Sets the default value.
      Parameters:
      defaultValue - the default value
      Returns:
      this instance
    • getCheckConstraintCondition

      public String getCheckConstraintCondition()
      Returns the check constraint condition.
      Returns:
      the check constraint condition
    • setCheckConstraintCondition

      public CreateTableColumn setCheckConstraintCondition(String checkConstraintCondition)
      Sets the check constraint condition.
      Parameters:
      checkConstraintCondition - the check constraint condition
      Returns:
      this instance
    • getCheckConstraintName

      public String getCheckConstraintName()
      Returns the check constraint name.
      Returns:
      the check constraint name
    • setCheckConstraintName

      public CreateTableColumn setCheckConstraintName(String checkConstraintName)
      Sets the check constraint name.
      Parameters:
      checkConstraintName - the check constraint name
      Returns:
      this instance
    • setCheckConstraint

      public CreateTableColumn setCheckConstraint(String checkConstraintName, String condition)
      Sets the check constraint name and condition.
      Parameters:
      checkConstraintName - the check constraint name
      condition - 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

      public CreateTableColumn setPrimaryKey(boolean primaryKey)
      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

      public CreateTableColumn setAutoIncrement(boolean autoIncrement)
      Sets whether the column has auto-increment enabled.
      Parameters:
      autoIncrement - true if the column has auto-increment enabled
      Returns:
      this instance