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
catalogName |
Name of the catalog |
|
all |
columnDataType |
Current data type of the column to add default value to |
informix |
all |
columnName |
Name of the column to add a default value to |
all |
all |
defaultValue |
Default value. Either this property or one of the other defaultValue * properties are required. |
|
all |
defaultValueBoolean |
|
|
all |
defaultValueComputed |
|
|
all |
defaultValueConstraintName |
|
|
all |
defaultValueDate |
|
|
all |
defaultValueNumeric |
|
|
all |
defaultValueSequenceNext |
|
|
all |
schemaName |
Name of the schema |
|
all |
tableName |
Name of the table to containing the column |
all |
all |
XML example
<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>
YAML example
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
JSON example
{ "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 example
ALTER TABLE cat.file ALTER fileName SET DEFAULT 'Something Else';
Database support
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
|