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

发布于 2024-10-05 12:57:38 字数 114 浏览 0 评论 0原文

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

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

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.

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

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

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

发布评论

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

评论(5

苏佲洛 2024-10-12 12:57:38

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

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

GRANT EXECUTE ON b.procedure_name TO a

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

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

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

CREATE SYNONYM procedure_name FOR b.procedure_name;

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

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

GRANT EXECUTE ON b.procedure_name TO a

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

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.

CREATE SYNONYM procedure_name FOR b.procedure_name;

BEGIN
  procedure_name( <<list of parameters>> );
END;
扶醉桌前 2024-10-12 12:57:38

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

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

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

编辑:

正如 Justin 提到的,向 A 授予 B 拥有的过程的执行权的方法:

GRANT EXECUTE ON b.procedure_name TO a;

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

The only privileges you can grant on procedures are EXECUTE and 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.

EDIT:

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

GRANT EXECUTE ON b.procedure_name TO a;
烛影斜 2024-10-12 12:57:38

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

因此,例如,如果您调用创建用户的包,则它是包所有者,而不是需要创建用户权限的调用用户。调用者只需要拥有包的执行权限即可。

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

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

希望这有帮助。

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

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

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

Hope this helps.

爱格式化 2024-10-12 12:57:38

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

该过程将看起来

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

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

On your DBA account, give USERB the right to create a procedure using 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

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

肩上的翅膀 2024-10-12 12:57:38
SQL> grant create any procedure to testdb;

当我们想要向“testdb”用户授予创建权限时,这是一个命令。

SQL> grant create any procedure to testdb;

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文