addDefaultValue
The addDefaultValue Change Type adds a default value to the database definition for the specified column in a table.
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 run this Change Type, follow these steps:
Add the Change Type to your changeset, as shown in the examples on this page.
Specify any required attributes. Use the table on this page to see which ones your database requires.
Deploy your changeset by running the
updatecommand:liquibase update
Now, you should see the default value created.
Available attributes
Name | Description | Required for | Supports |
| Name of the catalog | all | |
| Data type of the column. To help make scripts database-independent, Liquibase automatically converts the following generic data types to the correct database implementation: Also, specifying a
For Snowflake, Liquibase also implements For Databricks, Liquibase also implements Note: To specify a complex Databricks type like For more information, see How does Liquibase handle data types? | informix | all |
| Name of the column for which to add a default value. | all | all |
| The default value for fields in the column. Either this property or one of the other | all | |
| The boolean value that will be used if no value is provided. Note: Only one of the | all | |
| The default value returned from a function or procedure call of the same type as the column. Contains the function or column name to call. Differs from Note: Only one of the | The attribute is not supported by MySQL 8.0 or HyperSQL. In Liquibase 4.25.0+, it is supported by MySQL 5.7. | |
| Sets a unique name for default constraint used for a specific column. It works only along with any of the | The attribute is supported only by MSSQL. | |
| The default date and time value for column. The value is specified in one of the following forms: Note: Only one of the | all | |
| The default value for a column of a numeric type. For example: integer, bigint, bigdecimal, and others. Note: Only one of the | all | |
| 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. | Not supported by Apache Derby, Firebird, MySQL, MariaDB, SQLite, Ingress, and Sybase. | |
| Name of the schema | all | |
| Name of the table containing the column | all | all |
Troubleshooting
In the Liquibase Databricks extension 1.4.0, if you run addDefaultValue on a column in a table that already has columns with default values, you may receive this error:
DEFAULT values are not supported when adding new columns to previously existing Delta tables; please add the column without a default value first, then run a second ALTER TABLE ALTER COLUMN SET DEFAULT command to apply.
If you use a YAML, JSON, or XML changelog, instead of using addDefaultValue to generate this SQL query:
ALTER TABLE myTable ADD COLUMN eventShortDescription STRING DEFAULT 'short desc';
You must use the sql or sqlFile Change Types to run two SQL queries:
ALTER TABLE myTable ADD COLUMN eventShortDescription STRING;
ALTER TABLE myTable ALTER COLUMN eventShortDescription SET DEFAULT 'short desc';
Alternatively, you can deploy your addDefaultValue change using a formatted SQL changelog.
Database support
Database | Notes | Auto Rollback |
DB2/LUW | Supported | Yes |
DB2/z | Supported | Yes |
Derby | Supported | Yes |
Firebird | Supported | Yes |
Google BigQuery | 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 |
Snowflake | Not Supported | No |
SQL Server | Supported | Yes |
SQLite | Supported | Yes |
Sybase | Supported | Yes |
Sybase Anywhere | Supported | Yes |
addDefaultValue examples
--liquibase formatted sql
-- Sets 'active' as the default value for new rows in the users table
--changeset liquibase-docs:addDefaultValue-string
ALTER TABLE public.users
ALTER COLUMN status
SET DEFAULT 'active';
--rollback ALTER TABLE public.users ALTER COLUMN status DROP DEFAULT;
-- Sets 0.0 as the default rating for new products
--changeset liquibase-docs:addDefaultValue-numeric
ALTER TABLE products
ALTER COLUMN rating
SET DEFAULT 0.0;
--rollback ALTER TABLE products ALTER COLUMN rating DROP DEFAULT;
-- Marks all new user accounts as active by default
--changeset liquibase-docs:addDefaultValue-boolean
ALTER TABLE users
ALTER COLUMN is_active
SET DEFAULT TRUE;
--rollback ALTER TABLE users ALTER COLUMN is_active DROP DEFAULT;
-- Adds a fixed default timestamp for when orders are created
--changeset liquibase-docs:addDefaultValue-date
ALTER TABLE mydatabase.orders
ALTER COLUMN created_at
SET DEFAULT '2025-07-08 00:00:00';
--rollback ALTER TABLE mydatabase.orders ALTER COLUMN created_at DROP DEFAULT;
-- Uses CURRENT_TIMESTAMP so new sessions automatically record their start time
--changeset liquibase-docs:addDefaultValue-computed
ALTER TABLE sessions
ALTER COLUMN start_time
SET DEFAULT CURRENT_TIMESTAMP;
--rollback ALTER TABLE sessions ALTER COLUMN start_time DROP DEFAULT;
-- Assigns the next value from a sequence as the default invoice number
--changeset liquibase-docs:addDefaultValue-sequence
ALTER TABLE invoices
ALTER COLUMN invoice_number
SET DEFAULT NEXT VALUE FOR invoice_seq;
--rollback ALTER TABLE invoices ALTER COLUMN invoice_number DROP DEFAULT;