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

NameDescriptionRequired ForSupportsSince
catalogNameName of the catalogall3.0
columnDataTypeCurrent data type of the column to add default value toinformixall
columnNameName of the column to add a default value toallall
defaultValueDefault value. Either this property or one of the other defaultValue* properties are required.all
defaultValueBooleanall
defaultValueComputedall
defaultValueDateall
defaultValueNumericall
defaultValueSequenceNextall
schemaNameName of the schemaall
tableNameName of the table to containing the columnallall
<changeSet author="liquibase-docs" id="addDefaultValue-example">
    <addDefaultValue catalogName="cat"
            columnDataType="int"
            columnName="fileName"
            defaultValue="Something Else"
            defaultValueBoolean="true"
            defaultValueComputed="now"
            defaultValueDate="A String"
            defaultValueNumeric="A String"
            defaultValueSequenceNext="seq_name"
            schemaName="public"
            tableName="file"/>
</changeSet>
changeSet:
  id: addDefaultValue-example
  author: liquibase-docs
  changes:
  - addDefaultValue:
      catalogName: cat
      columnDataType: int
      columnName: fileName
      defaultValue: Something Else
      defaultValueBoolean: true
      defaultValueComputed: now
      defaultValueDate: A String
      defaultValueNumeric: A String
      defaultValueSequenceNext: seq_name
      schemaName: public
      tableName: file
{
  "changeSet": {
    "id": "addDefaultValue-example",
    "author": "liquibase-docs",
    "changes": [
      {
        "addDefaultValue": {
          "catalogName": "cat",
          "columnDataType": "int",
          "columnName": "fileName",
          "defaultValue": "Something Else",
          "defaultValueBoolean": true,
          "defaultValueComputed": "now",
          "defaultValueDate": "A String",
          "defaultValueNumeric": "A String",
          "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
DB2SupportedYes
DerbySupportedYes
FirebirdSupportedYes
H2SupportedYes
HyperSQLSupportedYes
InformixSupportedYes
MySQLSupportedYes
OracleSupportedYes
PostgreSQLSupportedYes
SQL ServerSupportedYes
SQLiteSupportedYes
SybaseSupportedYes
Sybase AnywhereSupportedYes

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