欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

開(kāi)發(fā)說(shuō)在用dwetl下執(zhí)行調(diào)用shop用戶(hù)下的表的時(shí)候提示沒(méi)有權(quán)限操作,google了查了下,發(fā)現(xiàn)oracle賬戶(hù)沒(méi)法直接賦予對(duì)某個(gè)表的truncate權(quán)限,那要怎么來(lái)實(shí)現(xiàn)呢?
在shop用戶(hù)下面,準(zhǔn)備測(cè)試數(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給一個(gè)用戶(hù)

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)限是在太大了,一不小心就會(huì)造成誤刪除,到時(shí)候哭都來(lái)不及啊

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,比較安全的做法

建立一個(gè)存儲(chǔ)過(guò)程p_truncate,在存儲(chǔ)過(guò)來(lái)里面執(zhí)行truncate table Z_TRUNCATE_T;然后賦予另外一個(gè)用戶(hù)dwetl對(duì)這個(gè)存儲(chǔ)過(guò)程的執(zhí)行權(quán)限。

存儲(chǔ)過(guò)程p_truncate如下:

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

建立存儲(chǔ)過(guò)程:

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

賦予存儲(chǔ)過(guò)程的執(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>

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

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

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

相關(guān)文章

最新評(píng)論