如何将序列的最小值设置为选择查询的结果?

发布于 2024-09-28 03:25:52 字数 261 浏览 2 评论 0原文

我试图在 oracle sql 中创建一个序列,使用“minvalue”作为选择查询的结果。

我尝试运行的选择查询是:

SELECT
      MAX(customer_id) + 1
FROM
      customer

我知道使用匿名 pl/sql 很容易,但我想找到一种不使用 pl/sql 的方法。我的一些想法包括使用 COLUMN 命令来设置替换变量,但我对如何做到这一点有点迷失。

提前致谢!

I am trying to create a sequence in oracle sql, using the "minvalue" as the result of a select query.

The select query I'm trying to run is:

SELECT
      MAX(customer_id) + 1
FROM
      customer

I know it's easy with an anonymous pl/sql, but I'd like to find a way which doesn't use pl/sql. Some ideas I've had include the COLUMN command to set a substitution variable, but I'm a little lost as to how to do that.

Thanks in advance!

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

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

发布评论

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

评论(1

沙沙粒小 2024-10-05 03:25:52

像这样:

column startval new_value v_startval

SELECT
      MAX(customer_id) + 1
FROM
      customer;

create sequence customer_seq start with &v_startval.;

Like this:

column startval new_value v_startval

SELECT
      MAX(customer_id) + 1
FROM
      customer;

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