将存储过程的权限授予另一个 Oracle 用户

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

Granting Rights on Stored Procedure to another user of Oracle

oraclestored-proceduresgrantownerrights-management

提问by Basmah

I am a student of Undergraduate studies , and I am facing little problem in granting rights of ownership to a user A to a stored procedure being owned by user B in database Oracle 10g mode =xe.

我是一名本科生,我在将所有权授予用户 A 到数据库 Oracle 10g 模式 =xe 中用户 B 拥有的存储过程方面几乎没有遇到任何问题。

Please help me in writing sql commands for granting rights of ownership on stored procedure xyz to another user A.

请帮助我编写 sql 命令,以将存储过程 xyz 的所有权授予另一个用户 A。

回答by Justin Cave

I'm not sure that I understand what you mean by "rights of ownership".

我不确定我是否理解您所说的“所有权”是什么意思。

If User B owns a stored procedure, User B can grant User A permission to run the stored procedure

如果用户 B 拥有存储过程,则用户 B 可以授予用户 A 运行存储过程的权限

GRANT EXECUTE ON b.procedure_name TO a

User A would then call the procedure using the fully qualified name, i.e.

然后用户 A 将使用完全限定名称调用该过程,即

BEGIN
  b.procedure_name( <<list of parameters>> );
END;

Alternately, User A can create a synonym in order to avoid having to use the fully qualified procedure name.

或者,用户 A 可以创建同义词以避免必须使用完全限定的过程名称。

CREATE SYNONYM procedure_name FOR b.procedure_name;

BEGIN
  procedure_name( <<list of parameters>> );
END;

回答by DCookie

You can't do what I think you're asking to do.

你不能做我认为你要求做的事情。

The only privileges you can grant on procedures are EXECUTE and DEBUG.

您可以授予过程的唯一权限是 EXECUTE 和 DEBUG。

If you want to allow user B to create a procedure in user A schema, then user B must have the CREATE ANY PROCEDURE privilege. ALTER ANY PROCEDURE and DROP ANY PROCEDURE are the other applicable privileges required to alter or drop user A procedures for user B. All are wide ranging privileges, as it doesn't restrict user B to any particular schema. User B should be highly trusted if granted these privileges.

如果要允许用户 B 在用户 A 模式中创建过程,则用户 B 必须具有 CREATE ANY PROCEDURE 权限。ALTER ANY PROCEDURE 和 DROP ANY PROCEDURE 是更改或删除用户 B 的用户 A 过程所需的其他适用权限。所有权限都是范围广泛的权限,因为它不会将用户 B 限制为任何特定模式。如果授予这些权限,用户 B 应该是高度信任的。

EDIT:

编辑:

As Justin mentioned, the way to give execution rights to A for a procedure owned by B:

正如贾斯汀所说,为 B 拥有的程序赋予 A 执行权的方法:

GRANT EXECUTE ON b.procedure_name TO a;

回答by Philip Johnson

Packages and stored procedures in Oracle execute by default using the rights of the package/procedure OWNER, not the currently logged on user.

默认情况下,Oracle 中的包和存储过程使用包/过程所有者的权限执行,而不是当前登录用户的权限。

So if you call a package that creates a user for example, its the package owner, not the calling user that needs create user privilege. The caller just needs to have execute permission on the package.

因此,如果您调用一个创建用户的包,例如,它是包所有者,而不是需要创建用户权限的调用用户。调用者只需要对包具有执行权限。

If you would prefer that the package should be run using the calling user's permissions, then when creating the package you need to specify AUTHID CURRENT_USER

如果您希望使用调用用户的权限运行包,那么在创建包时您需要指定 AUTHID CURRENT_USER

Oracle documentation "Invoker Rights vs Definer Rights" has more information http://docs.oracle.com/cd/A97630_01/appdev.920/a96624/08_subs.htm#18575

Oracle 文档“调用者权限与定义者权限”有更多信息http://docs.oracle.com/cd/A97630_01/appdev.920/a96624/08_subs.htm#18575

Hope this helps.

希望这可以帮助。

回答by JustinC

On your DBA account, give USERB the right to create a procedure using grant grant create any procedure to USERB

在您的 DBA 帐户上,授予 USERB 使用 grant 创建过程的权利 grant create any procedure to USERB

The procedure will look

该程序将看起来

CREATE OR REPLACE PROCEDURE USERB.USERB_PROCEDURE
--Must add the line below
AUTHID CURRENT_USER AS
  BEGIN
  --DO SOMETHING HERE
  END
END

GRANT EXECUTE ON USERB.USERB_PROCEDURE TO USERA

GRANT EXECUTE ON USERB.USERB_PROCEDURE TO USERA

I know this is a very old question but I am hoping I could chip it a bit.

我知道这是一个非常古老的问题,但我希望我能稍微解决一下。

回答by Raj Sharma

SQL> grant create any procedure to testdb;

This is a command when we want to give create privilege to "testdb" user.

当我们想为“testdb”用户提供创建权限时,这是一个命令。