oracle中实现某个用户truncate 其它用户下的表
假如想赋予jiao这个用户清空scott.t1这个表的权限,则可以在scott下创建一个清空该表的存储过程,然后将执行该存储过程的权限授予jiao用户。二 假如想清空某个用户下的多个表或所有表。则可以通过将存储过程的表名写成传参形式。
一 假如只想清空某个用户下某一个表
假如想赋予jiao这个用户清空scott.t1这个表的权限,则可以在scott下创建一个清空该表的存储过程,然后将执行该存储过程的权限授予jiao用户。
1.1 创建存储过程
create or replace procedure scott.p_truncate as
begin
execute immediate 'truncate table scott.t1';
end;
1.2 授予目标用户对该存储过程的执行权限
grant execute on scott.p_truncate to jiao
1.3 调用存储过程清空表
call scott.p_truncate();
二 假如想清空某个用户下的多个表或所有表
则可以通过将存储过程的表名写成传参形式。
2.1 创建存储过程
create procedure scott.stgtruncate(table_name in varchar2) as
begin
execute immediate 'truncate table '||table_name;
end;
2.2 授予目标用户对该存储过程的执行权限
grant execute on scott.stg
truncate to jiao ;
2.3 调用存储过程清空表
call scott.stgtruncate('t1');
--本篇文章参考自oracle中实现某个用户truncate 其它用户下的表_小戴BOTAOY演示博客,并做了些许改动。

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)