addDefaultValue

The addDefaultValue Change Type adds a default value to the database definition for the specified column.

Uses

You can typically use the addDefaultValue Change Type when you want to set the default value for the column definition.

Running the addDefaultValue Change Type

To add a default value to the database definition for a column, follow these steps:

Step 1: Add the addDefaultValue Change Type to your changeset with the needed attributes as it is shown in the examples. When using the addDefaultValue Change Type, you must set one of the following attributes: defaultValue, defaultValueNumeric, defaultValueBoolean, or defaultValueDate.

Step 2: Deploy your changeset by running the update command.

liquibase update

Now, you should see the default value created.

Available attributes

Name Description Required for Supports
catalogName The name of the catalog. all
columnDataType The current data type of the column for which to add a default value. informix all
columnName The name of the column for which to add a default value. all all
defaultValue The default value. Either this property or one of the other defaultValue* properties are required. all
defaultValueBoolean The attribute that sets the default value for a column of a boolean type. all
defaultValueComputed The attribute that sets the default value for a column using a function which returns value of the same type as the column has. The attribute is not supported by MySQL and HyperSQL.
defaultValueConstraintName The attribute that sets a unique name for default constraint used for a specific column. It works only along with any of defaultValue* attributes listed. The attribute is supported only by MSSQL.
defaultValueDate The attribute that sets the default value for a column of a date type. For example: timestamp, datetime, date, and others. all
defaultValueNumeric The attribute that sets the default value for a column of a numeric type. For example: integer, bigint, bigdecimal, and others. all
defaultValueSequenceNext The attribute that sets value for a specified column by using the value of the existing sequence. With every new input, the next value of the sequence will be taken. The attribute is not supported by Apache Derby, MySQL, MariaDB, SQLite, HyperSQL, Ingress, and Sybase.
schemaName The name of the schema. all
tableName The name of the table containing the column. all all

Database support

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