Oracle Sequence 开始有疑问

发布于 2024-12-01 04:00:29 字数 370 浏览 11 评论 0原文

我正在尝试对我的一张表中的 Id 字段进行自动编号。表已经有 40 行数据,但现在如果我自动编号 id 字段,我是否必须指定以 41 开头?谢谢

我必须这样做

create sequence EMP.SEQ_ID
minvalue 1
maxvalue 99999999999999999
start with 41
increment by 1
cache 50
order;

还是只有这个才有效

create sequence EMP.SEQ_ID
minvalue 1
maxvalue 99999999999999999
increment by 1
cache 50
order;

I am trying to autonumber Id field in one of my table. Table already has 40 rows of data but now if i autonumber the id field do i have to specify start with as 41 or not? Thank you

Do i have to do this

create sequence EMP.SEQ_ID
minvalue 1
maxvalue 99999999999999999
start with 41
increment by 1
cache 50
order;

or only this will work

create sequence EMP.SEQ_ID
minvalue 1
maxvalue 99999999999999999
increment by 1
cache 50
order;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼中杀气 2024-12-08 04:00:29

如果您不指定START WITH,则它从 1 开始。

因此,如果您将其用作主键并且已经存在 ID 从 1 到 40 的行,则会失败。

PS:你可以使用这个:(

CREATE SEQUENCE EMP.SEQ_ID
START WITH 41
NOMAXVALUE
CACHE 50;

默认加1)。

If you don't specify START WITH, it starts at 1.

So if you are using this for a primary key and there are already rows with IDs from 1 to 40, it will fail.

PS: You can use this:

CREATE SEQUENCE EMP.SEQ_ID
START WITH 41
NOMAXVALUE
CACHE 50;

(it increments by 1 by default).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文