且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Oracle 11G数据库中为主键列设置自动增量属性

更新时间:2022-04-25 09:30:15

根据您使用的Oracle DB的版本,您的方式是正确的这样做的方式。在12C之前,Oracle没有自动递增标识列的真正概念,但这非常有效。但是,从12C开始的Oracle版本中,引入了新功能。一种方法是这样的:
Depending on the version of Oracle DB you are using, the way you have done it is the correct way to do it. Prior to 12C, Oracle has no real concept of an automatically incrementing identity column, but this works perfectly well. In versions of Oracle from 12C on, though, new features were introduced. One way to do this is like this:
CREATE TABLE test_tab (
  id          NUMBER GENERATED ALWAYS AS IDENTITY,
  something   VARCHAR2(30)
);
insert into test_tab('something') values('Hi de hi');

您可以获得更多详细信息这里 [ ^ ]。

You can get more details here[^].