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 -

Change: ‘addDefaultValue’

Adds a default value to the database definition for the specified column. One of defaultValue, defaultValueNumeric, defaultValueBoolean or defaultValueDate must be set

Available Attributes

NameDescription
catalogNameName of the catalog@ v3.0E.g. 'cat'
columnDataTypeCurrent data type of the column to add default value toE.g. 'varchar(50)'Required for: informix
columnNameName of the column to add a default value toE.g. 'fileName'
defaultValueDefault value. Either this property or one of the other defaultValue* properties are required.E.g. 'Something Else'
defaultValueBooleanboolean
defaultValueComputed
defaultValueConstraintNameE.g. 'A String'
defaultValueDateE.g. '2008-02-12T12:34:03'
defaultValueNumericE.g. '439.2'
defaultValueSequenceNext
schemaNameName of the schemaE.g. 'public'
tableNameName of the table to containing the columnE.g. 'file'
<changeSet author="liquibase-docs" id="addDefaultValue-example">
    <addDefaultValue catalogName="cat"
            columnDataType="varchar(50)"
            columnName="fileName"
            defaultValue="Something Else"
            defaultValueBoolean="true"
            defaultValueComputed="now"
            defaultValueConstraintName="A String"
            defaultValueDate="2008-02-12T12:34:03"
            defaultValueNumeric="439.2"
            defaultValueSequenceNext="seq_name"
            schemaName="public"
            tableName="file"/>
</changeSet>
changeSet:
  id: addDefaultValue-example
  author: liquibase-docs
  changes:
  - addDefaultValue:
      catalogName: cat
      columnDataType: varchar(50)
      columnName: fileName
      defaultValue: Something Else
      defaultValueBoolean: true
      defaultValueComputed: now
      defaultValueConstraintName: A String
      defaultValueDate: 2008-02-12T12:34:03
      defaultValueNumeric: '439.2'
      defaultValueSequenceNext: seq_name
      schemaName: public
      tableName: file
{
  "changeSet": {
    "id": "addDefaultValue-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "addDefaultValue": {
          "catalogName": "cat",
          "columnDataType": "varchar(50)",
          "columnName": "fileName",
          "defaultValue": "Something Else",
          "defaultValueBoolean": true,
          "defaultValueComputed": "now",
          "defaultValueConstraintName": "A String",
          "defaultValueDate": "2008-02-12T12:34:03",
          "defaultValueNumeric": "439.2",
          "defaultValueSequenceNext": "seq_name",
          "schemaName": "public",
          "tableName": "file"
        }
      }]
    
  }
}

SQL Generated From Above Sample (MySQL)

ALTER TABLE cat.file ALTER fileName SET DEFAULT 'Something Else';

Database Support

DatabaseNotesAuto Rollback
DB2/LUWSupportedYes
DB2/zSupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
INGRESSupportedYes
InformixSupportedYes
MariaDBSupportedYes
MySQLSupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteSupportedYes
SybaseSupportedYes
Sybase AnywhereSupportedYes