Column tag

The “column” tag is a tag that is re-used throughout the Liquibase XML when column definitions and column information is needed. As a result, not all the attributes of column make sense in each context it is used in.

Available Attributes

Attribute Description
name Name of the column
type Column data type
value Value to set the column to. The value will be surrounded by quote marks and nested quote marks will be escaped.
computed Used if the value in "name" isn't actually a column name but actually a function. Since 3.3.0
valueNumeric Numeric value to set the column to. The value will not be escaped and will not be nested in quote marks.
valueBoolean Boolean value to set the column to. The actual value string inserted will be dependent on the database implementation.
valueDate Date and/or Time value to set the column to. The value is specified in one of the following forms: "YYYY-MM-DD", "hh:mm:ss" or "YYYY-MM-DDThh:mm:ss".
valueComputed A value that is returned from a function or procedure call. This attribute will contain the function to call.
valueBlobFile Path to a file, which contents will be written as a BLOB (i.e. chunk of binary data). Must be either absolute or relative to the Change Log file location (absolute paths are, e.g.: /usr/local/somefile.dat on Unix or c:\Directory\somefile.dat on Windows. Please refer to java.io.File javadoc for the details of what to consider relative/absolute path).
valueClobFile Path to a file, which contents will be written as a CLOB (i.e. chunk of character data). Must be either absolute or relative to the Change Log file location (absolute paths are, e.g.: /usr/local/somefile.dat on Unix or c:\Directory\somefile.dat on Windows. Please refer to java.io.File javadoc for the details of what to consider relative/absolute path).
encoding Name of the encoding (as specified in java.nio.Charset javadoc, e.g. "UTF-8") of the CLOB file (specified in valueClobFile) contents.

Note: used only when valueClobFile attribute is specified, ignored otherwise.
defaultValue Default value for column.
defaultValueNumeric Default numeric value for column
defaultValueBoolean Default boolean value for column
defaultValueDate Default date and/or time value for column. The value is specified in one of the following forms: "YYYY-MM-DD", "hh:mm:ss" or "YYYY-MM-DDThh:mm:ss"
defaultValueComputed A value that is returned from a function or procedure call. This attribute will contain the function to call.
autoIncrement Is column an auto-increment column. Ignored on databases that do not support autoincrement/identity functionality.
remarks Short description of the column (column comment)
beforeColumn If used in an 'addColumn' command, this attribute allows you to control where in the table column order the new column goes. Only one of beforeColumn, afterColumn or position are allowed. Since 3.1
afterColumn If used in an 'addColumn' command, this attribute allows you to control where in the table column order the new column goes. Only one of beforeColumn, afterColumn or position are allowed. Since 3.1
position If used in an 'addColumn' command, this attribute allows you to control where in the table column order the new column goes. Only one of beforeColumn, afterColumn or position are allowed. Expects a one based index Since 3.1

To help make scripts database-independent, the following “generic” data types will be converted to the correct database implementation:

  • BOOLEAN
  • CURRENCY
  • UUID
  • CLOB
  • BLOB
  • DATE
  • DATETIME
  • TIME
  • BIGINT

Also, specifying a java.sql.Types.* type will be converted to the correct type as well. If needed, precision can be included. Here are some examples:

  • java.sql.Types.TIMESTAMP
  • java.sql.Types.VARCHAR(255)

Available Sub-Tags

Tag Description
constraints Constraint definitions

Constraints tag

The “constraints” tag contains information about constraints on the column.

Available Attributes

Attribute Description
nullable Is column nullable?
primaryKey Is column a primary key?
primaryKeyName Primary key name Since 1.6
unique Should a unique clause be applied
uniqueConstraintName Unique constraint name
references Foreign key definition
foreignKeyName Foreign key name
deleteCascade Set delete cascade
deferrable Are constraints deferrable
initiallyDeferred Are constraints initially deferred

Missing, incomplete or wrong information? Please send a pull request