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

在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)