共计 2321 个字符,预计需要花费 6 分钟才能阅读完成。
本篇内容介绍了“怎么理解数据库的定义者权限与使用者权限”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让丸趣 TV 小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
我在 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;
CREATE OR REPLACE TYPE plch_numbers_t IS TABLE OF NUMBER
CREATE OR REPLACE FUNCTION plch_func
RETURN plch_numbers_t
AUTHID CURRENT_USER
l_numbers plch_numbers_t;
BEGIN
SELECT partnum
BULK COLLECT INTO l_numbers
FROM plch_parts;
RETURN l_numbers;
CREATE OR REPLACE VIEW plch_func_v
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;
/
哪些选项显示了下列语句块执行后屏幕上的输出结果?
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;
/
(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....
Battery
(D)
Two Cursor For Loops....
Battery
Steering Wheel
Brake Pedal
(E)
Two Cursor For Loops....
Battery
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....
Battery
PL/SQL procedure successfully completed
SQL
答案 C.
一个定义为调用者权限(AUTHID CURRENT_USER)的函数,如果它在一个 VIEW 或者触发器中被调用,这时是按照定义者的权限来运作的,所以你通过 VIEW 看到的将是 OWNER 的数据,而不是当前用户的数据。
“怎么理解数据库的定义者权限与使用者权限”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注丸趣 TV 网站,丸趣 TV 小编将为大家输出更多高质量的实用文章!
正文完