亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Oracle給用戶授權(quán)truncatetable的實(shí)現(xiàn)方案

 更新時間:2017年05月08日 17:24:16   投稿:mrr  
這篇文章主要介紹了Oracle給用戶授權(quán)truncatetable的實(shí)現(xiàn)方案,非常不錯,具有參考借鑒價值,需要的朋友可以參考下

1,對其它用戶下的表執(zhí)行trundate table操作

開發(fā)說在用dwetl下執(zhí)行調(diào)用shop用戶下的表的時候提示沒有權(quán)限操作,google了查了下,發(fā)現(xiàn)oracle賬戶沒法直接賦予對某個表的truncate權(quán)限,那要怎么來實(shí)現(xiàn)呢?
在shop用戶下面,準(zhǔn)備測試數(shù)據(jù)

SQL> create table Z_TRUNCATE_T(ID number);
Table created.
SQL> insert into Z_TRUNCATE_T select 1 from dual;
1 row created.
SQL> commit;
Commit complete.
SQL> select * from Z_TRUNCATE_T;
  ID
----------
   1
SQL>

2,比較粗魯不安全的做法

通常賦予truncate的常規(guī)做法,是直接賦值drop any table給一個用戶

SQL> grant drop any table to dwetl;
Grant succeeded.
SQL> 
SQL> grant select,insert,delete,update on Z_TRUNCATE_T to dwetl;
Grant succeeded.
SQL>

干完活,需要趕緊馬上收回權(quán)限因?yàn)閐rop any table權(quán)限是在太大了,一不小心就會造成誤刪除,到時候哭都來不及啊

SQL> revoke drop any table from dwetl;
Revoke succeeded.
SQL> revoke select,insert,delete,update on shop.PLAN6_TEMPLET_NODE_EDIT from dwetl;
Revoke succeeded.
SQL>

3,比較安全的做法

建立一個存儲過程p_truncate,在存儲過來里面執(zhí)行truncate table Z_TRUNCATE_T;然后賦予另外一個用戶dwetl對這個存儲過程的執(zhí)行權(quán)限。

存儲過程p_truncate如下:

create or replace procedure p_truncate as 
  begin
  execute immediate 'truncate table Z_TRUNCATE_T';
  end;

建立存儲過程:

SQL> 
 create or replace procedure p_truncate as 
begin
execute immediate 'truncate table Z_TRUNCATE_T';
 4 end;
 5 /
Procedure created.
SQL>

賦予存儲過程的執(zhí)行權(quán)限給dwetl,并且賦予表的增刪改查權(quán)限,因?yàn)閠runcate后,緊接著的基本就是insert、update、delete了

SQL> grant execute on p_truncate to dwetl;
Grant succeeded.
SQL> 
SQL> grant select,insert,delete,update on Z_TRUNCATE_T to dwetl;
Grant succeeded.
SQL>

通過dwetl賬號登陸,執(zhí)行存儲過程查看效果,看到shop用戶下的表Z_TRUNCATE_T已經(jīng)被清空了,ok,如此也證明了通過存儲過程這種方案是可行的,可以對別的用戶下的表進(jìn)行truncate table操作。
–查看

SQL> call shop.p_truncate();
Call completed.
SQL> select * from shop.Z_TRUNCATE_T;
no rows selected
SQL>

以上所述是小編給大家介紹的Oracle給用戶授權(quán)truncatetable的實(shí)現(xiàn)方案,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論