欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

ORA-08002: 序列XXXX尚未在此会话中定义

程序员文章站 2022-05-07 20:33:37
...
在pl/sql的sql窗口执行如下语句时,报ORA-08002错误。
select seq_test.currval from dual;

Solution Description:
---------------------

The NEXTVAL function acts as a sequence initializer. This can be misleading since in our example when we create the sequence we START WITH 1000. This does not however initialize the sequence. The first call to NEXTVAL initializes the sequence to the START WITH value. (Note that it does NOT increment the value.)

Solution Explanation:
---------------------

Before you can access CURRVAL for a sequence, you must first initialize the sequence with NEXTVAL.

序列授权:
Oracle

grant alter,select on seq_test to www;

PostgreSQL

GRANT USAGE, SELECT ON SEQUENCE cities_id_seq TO www;
GRANT USAGE - For sequences, this privilege allows the use of the currval and nextval functions.
相关标签: Oracle Sequence