您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容介绍了“怎么理解数据库的定义者权限与使用者权限”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
我在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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。