Oracle 授予更改序列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6514212/
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-19 00:05:34  来源:igfitidea点击:

Oracle grant alter sequence

oraclesequencealtergrant

提问by Eqbal

I have a grant alter sequenceto a user. But I have to specify the schema nameto 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/updatewithout specifying the schema name.

我有grant alter sequence一个用户。但我必须指定schema name改变序列,否则它会返回错误sequence does not exist。是否可以通过某种方式进行授权,这样我就不必指定架构名称?我可以select/insert/update不指定架构名称。

回答by Allan

Name resolution and access privileges are separate concepts. The grantgives 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:

名称解析和访问权限是不同的概念。的grant。给你的权限改变架构,但你还是通过你在命名空间受限的有四种方法可以让一个名字在一个模式的决心在另一:

  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;
  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 public synonym sequence_name for schema_name.sequence_name;

回答by eaolson

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.

回答by Randy

you may:

你可以:

ALTER SESSION SET CURRENT_SCHEMA myschema..

ALTER SESSION SET CURRENT_SCHEMA myschema..

then you can reference all items without the qualifier.

那么您可以在没有限定符的情况下引用所有项目。