本篇内容介绍了“怎么理解数据库的定义者权限与使用者权限”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
成都创新互联公司专注于企业成都全网营销、网站重做改版、泽普网站定制设计、自适应品牌网站建设、H5技术、商城开发、集团公司官网建设、成都外贸网站建设公司、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为泽普等各大城市提供网站开发制作服务。我在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的数据,而不是当前用户的数据。
“怎么理解数据库的定义者权限与使用者权限”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联-成都网站建设公司网站,小编将为大家输出更多高质量的实用文章!