Search code examples
oracle-databaseauto-incrementliquibase

Is Auto_Increment supported in Oracle using Liquibase


I want to add an auto_increment column in an oracle database using liquibase script.

I have tried using the auto_increment attribute in liquibase :

<column name="SUPPLEMENT_ID" type="INTEGER" autoIncrement="true" >
<constraints primaryKey="true"></constraints> 
</column>

If oracle supports auto_increment, how can I achieve it using liquibase scripts?


Solution

  • IDENTITY columns are introduced in oracle 12c which allows users to create auto increment columns

    But if you are using older versions you have to model the column with sequence and triggers as there is no such option as auto_increment or identity.

    Please see this answer on how to do it in both cases https://stackoverflow.com/a/11296469/8330426