SQL 序列不存在 ORA-02289

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25726573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:36:00  来源:igfitidea点击:

sequence doesn't exist ORA-02289

sqloracle

提问by user3752511

I have a problem getting my SEQUENCE. I have created a sequence as administrator and have grant select and alter privileges to the other user.

我在获取 SEQUENCE 时遇到问题。我以管理员身份创建了一个序列,并将选择和更改权限授予其他用户。

CREATE SEQUENCE  "OWNER"."TOT_SEQ"  MINVALUE 1000 MAXVALUE 1000000000 INCREMENT BY 1 START WITH 1000 CACHE 20 NOORDER  NOCYCLE ;

grant select,ALTER on TOT_SEQ to user;
commit;

When I do this :

当我这样做时:

select sequence_name from all_sequences;

TOT_SEQ

I can see my SEQUENCE in the list.

我可以在列表中看到我的 SEQUENCE。

But I can't access the sequence in my code. using :

但是我无法访问我的代码中的序列。使用 :

select <SEQUNCE_name>.nextval from dual;

What am I doing wrong?

我究竟做错了什么?

回答by gvenzl

You will either have to fully qualify your sequence via:

您必须通过以下方式完全限定您的序列:

SELECT <owner>.<sequence name>.nextval FROM dual;

Or create a public synonym for it:

或者为它创建一个公共同义词:

CREATE PUBLIC SYNONYM TOT_SEQ for OWNER.TOT_SEQ;
SELECT TOT_SEQ.nexval FROM DUAL;

回答by tak3shi

Make sure that you create the sequence in uppercase, even if you use lower case in trigger / select statement.

确保以大写形式创建序列,即使在 trigger/select 语句中使用小写也是如此。

回答by Rajesh Chamarthi

Have you tried using the fully qualified name in your code?

您是否尝试过在代码中使用完全限定名称?

select <owner>.<SEQUNCE_name>.nextval from dual;

If you already have, can you edit the question to post the output of the following commands. The "OWNER", "USER" in your examples are a bit confusing.

如果您已经有了,您能否编辑问题以发布以下命令的输出。您示例中的“所有者”、“用户”有点令人困惑。

select sequence, owner from all_sequences where sequence_name = 'TOT_SEQ'; select grantor, table_name, privilege from all_tab_privs where sequence_name = 'TOT_SEQ';

select sequence, owner from all_sequences where sequence_name = 'TOT_SEQ'; select grantor, table_name, privilege from all_tab_privs where sequence_name = 'TOT_SEQ';