Is there any way I can put the ID attribute incremental in changeset?

Is there any way I can put the ID attribute incremental in changeset

Hi @aynal,

We can make a column attribute (in your case ID) incremental by creating a sequence (supported in XML schema format for liquibase) for it.

Consider you want to create a table “Employee” and want it to have 2 columns as ID and Name. Below XML changeset will create the table Employee with these columns where in column named ID will be autoincremented on every insertion to table also the startValue specifies the initial value you want for the column to start with (in our case we can keep this as 1)

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns=""
<changeSet author="rakhi" id="create_table_employee" dbms="${dbType}">
	<createSequence sequenceName="emp_id_sequence" incrementBy="1" startValue="1" schemaName="dbSchema"/>
	<createTable tableName="Employee" schemaName="dbSchema">
		 <column name="ID" type="INTEGER" defaultValueComputed="nextval('dbSchema.emp_id_sequence')">
			 <constraints nullable="false" primaryKey="true" primaryKeyName="emp_id_pkey"/>
		<column name="Name" type="VARCHAR(100)">
			 <constraints nullable="false"/>

I have tried this and seems to be working for me. Please make sure to replace the correct schema name in the above changeset before giving it a try.

Let me know if this helps!