183.The HR user creates a stand-alone procedure as follows and grants the EXECUTE privilege on the
procedure to many database users:
CREATE OR REPLACE PROCEDURE create_dept ( v_deptno NUMBER, v_dname VARCHAR2, v_mgr
NUMBER, v_loc NUMBER)
BEGIN
INSERT INTO hr.departments VALUES (v_deptno, v_dname, v_mgr, v_loc);
END;
The users having permission to execute the procedure are able to insert records into the DEPARTMENTS
table even though they do not have the INSERT privilege on the table. You want only those users who
have privileges on the DEPARTMENTS table to be able to execute the procedure successfully.
What would you suggest to the PL/SQL developers to achieve this?
A.Create the procedure with definer's right.
B.Create the procedure with invoker's right.
C.Grant the EXECUTE privilege with GRANT OPTION on the procedure to selected users.
D.Create the procedure as part of a PL/SQL package and grant the EXECUTE privilege on the package to selected users.
答案:B
解析:这里问的主要是存储过程是调用者权限还是定义者权限
create procedure [or replace] [schema.]name[(parameter [in | out |in out] type [,... ])]
[AUTHID DEFINER | CURRENT_USER]
{ IS | AS }
[declarations]
begin
executable statements
[ exception
exception handlers]
end [name]
--说明: [AUTHID DEFINER | CURRENT_USER 定义该过程是用定义者(所有者)的权限运行,还是
--用当前用户的权限运行。前一种模式叫做定义者权限模型,后一种模式叫做调用者权限模型
--如果什么也不加,默认是定义者
因此这里如果想控制只有对DEPARTMENTS表具有权限的用户才可以通过存储过程插入的话,那么在创建过程的时候
应该使用调用者模式
procedure to many database users:
CREATE OR REPLACE PROCEDURE create_dept ( v_deptno NUMBER, v_dname VARCHAR2, v_mgr
NUMBER, v_loc NUMBER)
BEGIN
INSERT INTO hr.departments VALUES (v_deptno, v_dname, v_mgr, v_loc);
END;
The users having permission to execute the procedure are able to insert records into the DEPARTMENTS
table even though they do not have the INSERT privilege on the table. You want only those users who
have privileges on the DEPARTMENTS table to be able to execute the procedure successfully.
What would you suggest to the PL/SQL developers to achieve this?
A.Create the procedure with definer's right.
B.Create the procedure with invoker's right.
C.Grant the EXECUTE privilege with GRANT OPTION on the procedure to selected users.
D.Create the procedure as part of a PL/SQL package and grant the EXECUTE privilege on the package to selected users.
答案:B
解析:这里问的主要是存储过程是调用者权限还是定义者权限
create procedure [or replace] [schema.]name[(parameter [in | out |in out] type [,... ])]
[AUTHID DEFINER | CURRENT_USER]
{ IS | AS }
[declarations]
begin
executable statements
[ exception
exception handlers]
end [name]
--说明: [AUTHID DEFINER | CURRENT_USER 定义该过程是用定义者(所有者)的权限运行,还是
--用当前用户的权限运行。前一种模式叫做定义者权限模型,后一种模式叫做调用者权限模型
--如果什么也不加,默认是定义者
因此这里如果想控制只有对DEPARTMENTS表具有权限的用户才可以通过存储过程插入的话,那么在创建过程的时候
应该使用调用者模式