首先在存储过程中无法直接编译ddl语句,所以采用在execute immediate语句中执行ddl语句的方式
但是在存储过程中使用execute immediate执行ddl语句时,可能会报权限不足异常,如例:
create or replace procedure test_pro is
begin
execute immediate 'create table bosdata.acct_apply_bak as select * from bosdata.acct_apply';
end test_pro;
call test_pro();
1、authid current_user
首先在操作存储过程的用户下单独执行该ddl语句是有权限的,也就是说存储过程是没有权限的,所以让存储过程继承操作用户的权限就可以了
create or replace procedure test_pro authid current_user is
begin
execute immediate 'create table bosdata.acct_apply_bak as select * from bosdata.acct_apply';
end test_pro;
2、grant create any table to user;
但是在job定时任务中仍然无法执行成功
grant create any table to bosdata;
给用户赋予create any table权限之后就可以了