更新时间: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[^].