您好,登錄后才能下訂單哦!
本篇內容介紹了“怎么理解數據庫的定義者權限與使用者權限”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
我在HR模式下運行了下列語句(沒有發生錯誤):
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模式并執行如下語句:
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; /
哪些選項顯示了下列語句塊執行后屏幕上的輸出結果?
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
實測答案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.
一個定義為調用者權限(AUTHID CURRENT_USER)的函數,如果它在一個VIEW或者觸發器中被調用,這時是按照定義者的權限來運作的,所以你通過VIEW看到的將是OWNER的數據,而不是當前用戶的數據。
“怎么理解數據庫的定義者權限與使用者權限”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。