GRANT SELECT不适用于序列

时间:2019-05-20 20:08:10

标签: oracle

我已经在所有者帐户下创建了xyz序列,并为'abc'数据库用户授予了选择特权,但是,当我尝试选择序列时,它说该序列不使用abc用户存在。

所有者帐户

CREATE SEQUENCE XYZ MINVALUE 0 START WITH 1 INCREMENT BY 1;

GRANT SELECT ON XYZ TO ABC;

ABC帐户

select XYZ.nextval from dual;

我应该使用ABC帐户访问XYZ.nextval。对此的任何帮助都非常感谢如何解决此问题

1 个答案:

答案 0 :(得分:1)

看来您缺少序列所有者名称。

一个示例(实际上起作用)。

SQL> show user
USER is "SCOTT"
SQL>
SQL> create sequence seq;

Sequence created.

SQL> grant select on seq to hr;

Grant succeeded.

SQL> connect hr/hr
Connected.
SQL>
SQL> select scott.seq.nextval from dual;      --> owner.sequence name.nextval

   NEXTVAL
----------
         1

SQL>

同义词:

SQL> connect hr/hr
Connected.
SQL> create synonym seq for scott.seq;

Synonym created.

SQL> select seq.nextval from dual;

   NEXTVAL
----------
         2

SQL>

公共同义词:

SQL> connect scott/tiger
Connected.
SQL> create public synonym seq for seq;

Synonym created.

SQL> connect hr/hr
Connected.
SQL> select seq.nextval from dual;

   NEXTVAL
----------
         3

SQL>