Class CreateTableColumn
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.sql.mysql.MySqlPart
com.northconcepts.datapipeline.sql.mysql.CreateTableColumn
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 Summary
ConstructorsConstructorDescriptionCreateTableColumn(String columnName, TableColumnType type) CreateTableColumn(String columnName, TableColumnType type, Integer length) CreateTableColumn(String columnName, TableColumnType type, Integer length, Integer 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 condition written verbatim insideCHECK (...); null or blank omits the check constraint.Returns the name of the check constraint; an unnamedCHECKis written when it is null or blank.Returns the SQL expression written verbatim afterDEFAULT; null or blank omits the clause.Returns the length or precision written after the type, or null for none; ignored if the type does not support one.getScale()Returns the scale written after the length, or null for none; ignored unless the type supports it and a length is set.getType()booleanIndicates ifAUTO_INCREMENTis written; only applies to types whoseTableColumnType.isAutoIncrementSupported()is true.booleanIndicates if the column accepts nulls;NOT NULLis written when false (default true).booleanIndicates ifCreateTablelists the column in the table'sPRIMARY KEYclause.booleanisUnique()setAutoIncrement(boolean autoIncrement) Indicates ifAUTO_INCREMENTis written; only applies to types whoseTableColumnType.isAutoIncrementSupported()is true.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.setCheckConstraintCondition(String checkConstraintCondition) Sets the condition written verbatim insideCHECK (...); null or blank omits the check constraint.setCheckConstraintName(String checkConstraintName) Sets the name of the check constraint; an unnamedCHECKis written when it is null or blank.setColumnName(String columnName) setDefaultValue(String defaultValue) Sets the SQL expression written verbatim afterDEFAULT(quote string literals yourself); null or blank omits it.Sets the length or precision written after the type, or null for none; ignored if the type does not support one.setNullable(boolean nullable) Indicates if the column accepts nulls;NOT NULLis written when false (default true).setPretty(boolean pretty) Indicates ifSqlPart.getSqlFragment()adds line breaks and indentation instead of using one line (default is false).setPrimaryKey(boolean primaryKey) Indicates ifCreateTablelists the column in the table'sPRIMARY KEYclause.Sets the scale written after the length, or null for none; ignored unless the type supports it and a length is set.setType(TableColumnType type) setUnique(boolean unique) Methods inherited from class com.northconcepts.datapipeline.sql.mysql.MySqlPart
escapeKeyword, placeBackTicksMethods inherited from class com.northconcepts.datapipeline.jdbc.sql.SqlPart
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
-
Constructor Details
-
CreateTableColumn
public CreateTableColumn() -
CreateTableColumn
-
CreateTableColumn
-
CreateTableColumn
-
-
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
-
setColumnName
-
getType
-
setType
-
getLength
Returns the length or precision written after the type, or null for none; ignored if the type does not support one. -
setLength
Sets the length or precision written after the type, or null for none; ignored if the type does not support one. -
getScale
Returns the scale written after the length, or null for none; ignored unless the type supports it and a length is set. -
setScale
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 NULLis written when false (default true). -
setNullable
Indicates if the column accepts nulls;NOT NULLis written when false (default true). -
isUnique
public boolean isUnique() -
setUnique
-
getDefaultValue
Returns the SQL expression written verbatim afterDEFAULT; null or blank omits the clause. -
setDefaultValue
Sets the SQL expression written verbatim afterDEFAULT(quote string literals yourself); null or blank omits it. -
getCheckConstraintCondition
Returns the condition written verbatim insideCHECK (...); null or blank omits the check constraint. -
setCheckConstraintCondition
Sets the condition written verbatim insideCHECK (...); null or blank omits the check constraint. -
getCheckConstraintName
Returns the name of the check constraint; an unnamedCHECKis written when it is null or blank. -
setCheckConstraintName
Sets the name of the check constraint; an unnamedCHECKis written when it is null or blank. -
setCheckConstraint
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 ifCreateTablelists the column in the table'sPRIMARY KEYclause. -
setPrimaryKey
Indicates ifCreateTablelists the column in the table'sPRIMARY KEYclause. -
isAutoIncrement
public boolean isAutoIncrement()Indicates ifAUTO_INCREMENTis written; only applies to types whoseTableColumnType.isAutoIncrementSupported()is true. -
setAutoIncrement
Indicates ifAUTO_INCREMENTis written; only applies to types whoseTableColumnType.isAutoIncrementSupported()is true.
-