错误:ORA-01031:权限不足

时间:2015-07-18 02:50:22

标签: oracle oracle11g oracle-sqldeveloper

我有一个问题。

CREATE TABLE accounts(
  id INTEGER, 
  name VARCHAR2(100)
)
/

CREATE OR REPLACE FUNCTION account_balance(account_id_in IN accounts.id%TYPE)
RETURN NUMBER
IS
BEGIN
  RETURN 0;
END;
/

错误:

Error starting at line : 1 in command -
CREATE OR REPLACE FUNCTION account_balance(account_id_in IN accounts.id%TYPE)
RETURN NUMBER
IS
BEGIN
  RETURN 0;
END;
Error report -
ORA-01031: insufficient privileges
01031. 00000 -  "insufficient privileges"
*Cause:    An attempt was made to perform a database operation without
           the necessary privileges.
*Action:   Ask your database administrator or designated security
           administrator to grant you the necessary privileges

enter image description here

请帮我解决以上错误,谢谢!

2 个答案:

答案 0 :(得分:3)

正如评论中指出的那样,您缺少从当前使用的任何用户帐户创建函数所需的权限。

假设您的特权较低的登录名为some_user。要解决您的问题,请以更高权限的帐户登录,并应用以下GRANT声明:

grant create procedure to some_user;

文档:GRANT

  

CREATE PROCEDURE:在被授权者的架构中创建存储过程,函数和包。

答案 1 :(得分:0)

登录为

sys as sysdba

然后将用户名更改为您的用户名后执行以下命令

GRANT CREATE PROCEDURE TO username;