Oracle 架构用户无法在过程中创建 table
Oracle schema user cannot create table in procedure
我正在尝试在以下过程中创建临时 table:
PROCEDURE pr_create_tmp_bp_table(fp_id NUMBER) IS
tbl_name CONSTANT VARCHAR2(20) := 'BP_TO_DELETE';
BEGIN
-- sanity checks removed for readablity
EXECUTE IMMEDIATE
'CREATE GLOBAL TEMPORARY TABLE ' || tbl_name || ' ' ||
'ON COMMIT PRESERVE ROWS AS ' ||
'SELECT * FROM infop_stammdaten.bp';
END;
如果我将 BEGIN.._END
块复制到 SQL 作品sheet 一切正常。所以我认为用户有权创建临时table。如果我从同一个 SQL worksheet 执行程序,我会得到
Fehlerbericht -
ORA-01031: Nicht ausreichende Berechtigungen
ORA-06512: in "INFOP_STAMMDATEN.PA_DELETE_FP", Zeile 16
ORA-06512: in Zeile 6
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
第 16 行 (Zeile 16) 指向创建临时 table.
的 EXECUTE IMMEDIATE 语句
在我看来,用户在 sql 工作中没有相同的权限 sheet 并且当它执行一个过程时,该过程也在它自己的模式中。
您的直接问题的答案是您得到 ORA-01031: insufficient privileges
因为您的用户具有通过角色授予的 CREATE TABLE 权限:Oracle 安全模型强制执行我们不能使用的规则通过 PL/SQL 中的角色授予的特权。因此,您需要您的 DBA 直接将 CREATE TABLE 权限授予您的用户。
或者你呢?
因为您尝试做的事情在 Oracle 中没有意义。在 Oracle global temporary table 中是 permanent 结构;只是其中的数据是临时的。因此,正确的解决方案是使用普通 DDL 脚本构建 table 一次,就像任何其他数据库对象一样。然后你可以根据需要插入全局临时 table。
您不是本网站上第一个犯此错误的人 (). Often it's because people are coming from another database such as SQL Server which has a construct called "temporary table" which is actually different from Oracle's global temporary tables. If that's your scenario then you will be interested in an Oracle 18c new feature called Private Temporary Tables. These are exactly analogous to SQL Server temporary tables. Find out more。
我正在尝试在以下过程中创建临时 table:
PROCEDURE pr_create_tmp_bp_table(fp_id NUMBER) IS
tbl_name CONSTANT VARCHAR2(20) := 'BP_TO_DELETE';
BEGIN
-- sanity checks removed for readablity
EXECUTE IMMEDIATE
'CREATE GLOBAL TEMPORARY TABLE ' || tbl_name || ' ' ||
'ON COMMIT PRESERVE ROWS AS ' ||
'SELECT * FROM infop_stammdaten.bp';
END;
如果我将 BEGIN.._END
块复制到 SQL 作品sheet 一切正常。所以我认为用户有权创建临时table。如果我从同一个 SQL worksheet 执行程序,我会得到
Fehlerbericht -
ORA-01031: Nicht ausreichende Berechtigungen
ORA-06512: in "INFOP_STAMMDATEN.PA_DELETE_FP", Zeile 16
ORA-06512: in Zeile 6
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
第 16 行 (Zeile 16) 指向创建临时 table.
的 EXECUTE IMMEDIATE 语句在我看来,用户在 sql 工作中没有相同的权限 sheet 并且当它执行一个过程时,该过程也在它自己的模式中。
您的直接问题的答案是您得到 ORA-01031: insufficient privileges
因为您的用户具有通过角色授予的 CREATE TABLE 权限:Oracle 安全模型强制执行我们不能使用的规则通过 PL/SQL 中的角色授予的特权。因此,您需要您的 DBA 直接将 CREATE TABLE 权限授予您的用户。
或者你呢?
因为您尝试做的事情在 Oracle 中没有意义。在 Oracle global temporary table 中是 permanent 结构;只是其中的数据是临时的。因此,正确的解决方案是使用普通 DDL 脚本构建 table 一次,就像任何其他数据库对象一样。然后你可以根据需要插入全局临时 table。
您不是本网站上第一个犯此错误的人 (