Oracle 授予更改序列

发布于 2024-11-17 09:41:59 字数 168 浏览 4 评论 0原文

我有一个授予更改序列给用户。但我必须指定模式名称来更改序列,否则它会返回错误序列不存在。是否可以以某种方式进行授权,这样我就不必指定架构名称?我可以在不指定架构名称的情况下执行select/insert/update

I have a grant alter sequence to a user. But I have to specify the schema name to alter the sequence otherwise it comes back with error sequence does not exist. Is it possible to do the grant in a way so I don't have to specify the schema name? I can do select/insert/update without specifying the schema name.

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

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

发布评论

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

评论(3

谁对谁错谁最难过 2024-11-24 09:42:00

听起来您以与拥有该序列的用户不同的用户身份连接到数据库。在这种情况下,您需要在序列前面加上模式,否则您所讨论的序列会很模糊。

如果您作为拥有用户连接到数据库,则不需要架构限定符:

SQL> create sequence foo;

Sequence created.

SQL> grant alter on foo to hr;

Grant succeeded.

It sounds like you're connected to your database as a different user than the one that owns the sequence. In that case, you will need to preface the sequence with the schema, otherwise it's ambiguous as to what sequence you're talking about.

If you are connected to your database as the owning user, you do not need the schema qualifier:

SQL> create sequence foo;

Sequence created.

SQL> grant alter on foo to hr;

Grant succeeded.
标点 2024-11-24 09:42:00

您可以:

ALTER SESSION SET CURRENT_SCHEMA myschema..

然后您可以引用所有不带限定符的项目。

you may:

ALTER SESSION SET CURRENT_SCHEMA myschema..

then you can reference all items without the qualifier.

高跟鞋的旋律 2024-11-24 09:41:59

名称解析和访问权限是不同的概念。 grant 授予您更改架构的权限,但您仍然受到所在命名空间的限制。有四种方法可以使一个架构中的名称在另一个

  1. 架构 中解析:对象名称:
    select schema_name.sequence_name.nextval from Dual;
  2. 更改当前会话以解析名称,就像您在其他架构中一样:
    alter session set current_schema = schema_name;
  3. 为当前模式中的对象创建同义词:
    create synonym sequence_name for schema_name.sequence_name;
  4. 为对象创建公共同义词:
    create schema_name.sequence_name 的公共同义词sequence_name;

Name resolution and access privileges are separate concepts. The grant gives you permission to alter the schema, but you're still constrained by the namespace you're in. There are four ways to make a name in one schema resolve in another:

  1. Reference the schema with the object name:
    select schema_name.sequence_name.nextval from dual;
  2. Alter the current session to resolve names as if you were in the other schema:
    alter session set current_schema = schema_name;
  3. Create a synonym for the object in the current schema:
    create synonym sequence_name for schema_name.sequence_name;
  4. Create a public synonym for the object:
    create public synonym sequence_name for schema_name.sequence_name;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文