Liquibase® version 3.8.5 is now available! Get it for free.
2018 XML Announcement
News All Previous Posts >>

Subscribe for email updates

- and/or -

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. Please note that setting the "value" attribute will set all rows existing to the specified value without modifying the column default. Setting the "defaultValue" attribute will specify a default value for the column.
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, whose 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, whose 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.
Note: If not set the first defaultValueXXX defined is used in the order they appear.
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.
startWith The value auto-increment start. Ignored on databases that do not support autoincrement/identity functionality.
incrementBy The value of each step by auto-increment. 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
descending If used in a 'createIndex' command, this boolean attribute allows you to specify that a column should be used in descending order in the index. Defaults to false (i.e. ascending order) Since 3.4

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?
notNullConstraintName The not null constraint name
primaryKey Is column a primary key?
primaryKeyName Primary key name Since 1.6
primaryKeyTablespace The tablespace to use for the defined primary key
unique Should a unique clause be applied?
uniqueConstraintName The unique constraint name
references Foreign key definition
referencedTableCatalogName Name of the catalog
referencedTableSchemaName Name of the schema
referencedTableName Name of the table
referencedColumnNames Name of the column
foreignKeyName Foreign key name
deleteCascade Set delete cascade
deferrable Are constraints deferrable?
initiallyDeferred Are constraints initially deferred?
validateNullable Should validate the defined not null constraint?
validateUnique Should validate the defined unique constraint?
validatePrimaryKey Should validate the defined primary key constraint?
validateForeignKey Should validate the defined foreign key constraint?
checkConstraint Should validate the defined check constraint?