本篇內(nèi)容介紹了“怎么理解數(shù)據(jù)庫(kù)的定義者權(quán)限與使用者權(quán)限”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
為和布克賽爾蒙古等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及和布克賽爾蒙古網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站建設(shè)、做網(wǎng)站、和布克賽爾蒙古網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!
我在HR模式下運(yùn)行了下列語(yǔ)句(沒有發(fā)生錯(cuò)誤):
CREATE TABLE plch_parts ( partnum NUMBER , partname VARCHAR2 (50) ) / BEGIN INSERT INTO plch_parts VALUES (123, 'Steering Wheel'); INSERT INTO plch_parts VALUES (456, 'Brake Pedal'); COMMIT; END; / CREATE OR REPLACE TYPE plch_numbers_t IS TABLE OF NUMBER / CREATE OR REPLACE FUNCTION plch_func RETURN plch_numbers_t AUTHID CURRENT_USER IS l_numbers plch_numbers_t; BEGIN SELECT partnum BULK COLLECT INTO l_numbers FROM plch_parts; RETURN l_numbers; END; / CREATE OR REPLACE VIEW plch_func_v AS SELECT COLUMN_VALUE partnum FROM TABLE (plch_func ()) / GRANT SELECT ON plch_func_v TO scott / GRANT EXECUTE ON plch_func TO scott /
然后我又連接到SCOTT模式并執(zhí)行如下語(yǔ)句:
CREATE TABLE plch_parts ( partnum NUMBER , partname VARCHAR2 (50) ) / BEGIN INSERT INTO plch_parts VALUES (100, 'Tire'); INSERT INTO plch_parts VALUES (101, 'Battery'); COMMIT; END; /
哪些選項(xiàng)顯示了下列語(yǔ)句塊執(zhí)行后屏幕上的輸出結(jié)果?
BEGIN DBMS_OUTPUT.put_line ('Two Cursor For Loops....'); FOR rec IN ( SELECT p.partname FROM TABLE (hr.plch_func) v, plch_parts p WHERE v.column_value = p.partnum ORDER BY p.partnum) LOOP DBMS_OUTPUT.put_line (rec.partname); END LOOP; FOR rec IN ( SELECT p.partname FROM hr.plch_func_v v, plch_parts p WHERE v.partnum = p.partnum ORDER BY p.partnum) LOOP DBMS_OUTPUT.put_line (rec.partname); END LOOP; END; /
(A)
Two Cursor For Loops.... Steering Wheel Brake Pedal
(B)
An unhandled exception: PLS-00158: AUTHID CURRENT_USER subprograms not allowed in views
(C)
Two Cursor For Loops.... Tire Battery
(D)
Two Cursor For Loops.... Tire Battery Steering Wheel Brake Pedal
(E)
Two Cursor For Loops.... Tire Battery Tire Battery
實(shí)測(cè)答案C
SQL> BEGIN 2 DBMS_OUTPUT.put_line ('Two Cursor For Loops....'); 3 4 FOR rec IN ( SELECT p.partname 5 FROM TABLE (yoga.plch_func) v, plch_parts p 6 WHERE v.column_value = p.partnum 7 ORDER BY p.partnum) 8 LOOP 9 DBMS_OUTPUT.put_line (rec.partname); 10 END LOOP; 11 12 FOR rec IN ( SELECT p.partname 13 FROM yoga.plch_func_v v, plch_parts p 14 WHERE v.partnum = p.partnum 15 ORDER BY p.partnum) 16 LOOP 17 DBMS_OUTPUT.put_line (rec.partname); 18 END LOOP; 19 END; 20 / Two Cursor For Loops.... Tire Battery PL/SQL procedure successfully completed SQL>
答案C.
一個(gè)定義為調(diào)用者權(quán)限(AUTHID CURRENT_USER)的函數(shù),如果它在一個(gè)VIEW或者觸發(fā)器中被調(diào)用,這時(shí)是按照定義者的權(quán)限來(lái)運(yùn)作的,所以你通過(guò)VIEW看到的將是OWNER的數(shù)據(jù),而不是當(dāng)前用戶的數(shù)據(jù)。
“怎么理解數(shù)據(jù)庫(kù)的定義者權(quán)限與使用者權(quán)限”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!