Adds a default value to the database definition for the specified column. One of defaultValue, defaultValueNumeric, defaultValueBoolean or defaultValueDate must be set
| Name | Description |
|---|---|
| catalogName | Name of the catalog@ v3.0E.g. 'cat' |
| columnDataType | Current data type of the column to add default value toE.g. 'varchar(50)'Required for: informix |
| columnName | Name of the column to add a default value toE.g. 'fileName' |
| defaultValue | Default value. Either this property or one of the other defaultValue* properties are required.E.g. 'Something Else' |
| defaultValueBoolean | boolean |
| defaultValueComputed | |
| defaultValueConstraintName | E.g. 'A String' |
| defaultValueDate | E.g. '2008-02-12T12:34:03' |
| defaultValueNumeric | E.g. '439.2' |
| defaultValueSequenceNext | |
| schemaName | Name of the schemaE.g. 'public' |
| tableName | Name 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"
}
}]
}
}ALTER TABLE cat.file ALTER fileName SET DEFAULT 'Something Else';| Database | Notes | Auto Rollback |
|---|---|---|
| DB2/LUW | Supported | Yes |
| DB2/z | Supported | Yes |
| Derby | Supported | Yes |
| Firebird | Supported | Yes |
| H2 | Supported | Yes |
| HyperSQL | Supported | Yes |
| INGRES | Supported | Yes |
| Informix | Supported | Yes |
| MariaDB | Supported | Yes |
| MySQL | Supported | Yes |
| Oracle | Supported | Yes |
| PostgreSQL | Supported | Yes |
| SQL Server | Supported | Yes |
| SQLite | Supported | Yes |
| Sybase | Supported | Yes |
| Sybase Anywhere | Supported | Yes |