Class CreateTableColumn


public class CreateTableColumn extends MySqlPart

Generates a column definition for a CREATE TABLE statement for MySQL.


Sample Generated SQL:

email TEXT NOT NULL, CONSTRAINT "email_check" CHECK (email LIKE '%@%')
  • Constructor Details

  • 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()
    • setColumnName

      public CreateTableColumn setColumnName(String columnName)
    • getType

      public TableColumnType getType()
    • setType

      public CreateTableColumn setType(TableColumnType type)
    • getLength

      public Integer getLength()
      Returns the length or precision written after the type, or null for none; ignored if the type does not support one.
    • setLength

      public CreateTableColumn setLength(Integer length)
      Sets the length or precision written after the type, or null for none; ignored if the type does not support one.
    • getScale

      public Integer getScale()
      Returns the scale written after the length, or null for none; ignored unless the type supports it and a length is set.
    • setScale

      public CreateTableColumn setScale(Integer scale)
      Sets the scale written after the length, or null for none; ignored unless the type supports it and a length is set.
    • isNullable

      public boolean isNullable()
      Indicates if the column accepts nulls; NOT NULL is written when false (default true).
    • setNullable

      public CreateTableColumn setNullable(boolean nullable)
      Indicates if the column accepts nulls; NOT NULL is written when false (default true).
    • isUnique

      public boolean isUnique()
    • setUnique

      public CreateTableColumn setUnique(boolean unique)
    • getDefaultValue

      public String getDefaultValue()
      Returns the SQL expression written verbatim after DEFAULT; null or blank omits the clause.
    • setDefaultValue

      public CreateTableColumn setDefaultValue(String defaultValue)
      Sets the SQL expression written verbatim after DEFAULT (quote string literals yourself); null or blank omits it.
    • getCheckConstraintCondition

      public String getCheckConstraintCondition()
      Returns the condition written verbatim inside CHECK (...); null or blank omits the check constraint.
    • setCheckConstraintCondition

      public CreateTableColumn setCheckConstraintCondition(String checkConstraintCondition)
      Sets the condition written verbatim inside CHECK (...); null or blank omits the check constraint.
    • getCheckConstraintName

      public String getCheckConstraintName()
      Returns the name of the check constraint; an unnamed CHECK is written when it is null or blank.
    • setCheckConstraintName

      public CreateTableColumn setCheckConstraintName(String checkConstraintName)
      Sets the name of the check constraint; an unnamed CHECK is written when it is null or blank.
    • setCheckConstraint

      public CreateTableColumn setCheckConstraint(String checkConstraintName, String condition)
      Sets the name and condition of a check constraint that is written after the column definition, separated by a comma.
    • isPrimaryKey

      public boolean isPrimaryKey()
      Indicates if CreateTable lists the column in the table's PRIMARY KEY clause.
    • setPrimaryKey

      public CreateTableColumn setPrimaryKey(boolean primaryKey)
      Indicates if CreateTable lists the column in the table's PRIMARY KEY clause.
    • isAutoIncrement

      public boolean isAutoIncrement()
      Indicates if AUTO_INCREMENT is written; only applies to types whose TableColumnType.isAutoIncrementSupported() is true.
    • setAutoIncrement

      public CreateTableColumn setAutoIncrement(boolean autoIncrement)
      Indicates if AUTO_INCREMENT is written; only applies to types whose TableColumnType.isAutoIncrementSupported() is true.