使用Liquibase在Oracle中是否支持Auto_Increment [英] Is Auto_Increment supported in Oracle using Liquibase
问题描述
我想使用liquibase脚本在oracle数据库中添加一个auto_increment列.
I want to add an auto_increment column in an oracle database using liquibase script.
我尝试在liquibase中使用 auto_increment
属性:
I have tried using the auto_increment
attribute in liquibase :
<column name="SUPPLEMENT_ID" type="INTEGER" autoIncrement="true" >
<constraints primaryKey="true"></constraints>
</column>
如果oracle支持auto_increment,如何使用liquibase脚本实现它?
If oracle supports auto_increment, how can I achieve it using liquibase scripts?
推荐答案
在Oracle 12c中引入了IDENTITY列,该列允许用户创建自动增量列
IDENTITY columns are introduced in oracle 12c which allows users to create auto increment columns
但是,如果您使用的是旧版本,则必须使用序列和触发器对列进行建模,因为没有诸如auto_increment或identity这样的选项.
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.
请在两种情况下查看此答案,以了解如何做 https://stackoverflow.com/a/11296469/8330426
Please see this answer on how to do it in both cases https://stackoverflow.com/a/11296469/8330426
这篇关于使用Liquibase在Oracle中是否支持Auto_Increment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!