本篇内容介绍了“怎么理解数据库的定义者权限与使用者权限”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
为和布克赛尔蒙古等地区用户提供了全套网页设计制作服务,及和布克赛尔蒙古网站建设行业解决方案。主营业务为网站建设、做网站、和布克赛尔蒙古网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
我在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的数据,而不是当前用户的数据。
“怎么理解数据库的定义者权限与使用者权限”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!