Section 9
Section 9
How do
you Mark for Review
specify (1) Points
that you
want a
procedure
MYPROCA
to use
"Definer's
Rights"?
Correct
2. User BOB creates procedure MYPROC using the default Definer's Rights. BOB
then executes: Mark for Review
GRANT EXECUTE ON bob.myproc TO ted; (1) Points
When TED invokes BOB.MYPROC, whose privileges are checked?
SYSTEM's privileges
TED's privileges
PUBLIC's privileges
BOB's privileges (*)
ORACLE's privileges
Correct
Which variable is passed to the function and which variable is returned from the
function?
EMPLOYEE_ID is passed and SALARY is returned.
SALARY is passed and P_ID is returned.
P_ID is passed and V_SAL is returned. (*)
GET_SAL is passed and V_SAL is returned.
Correct
6. You want to
allow user Mark for Review
JOE to query (1) Points
the
CD_DETAILS
table in your
schema.
Which
command
should you
use?
7. Your schema contains two procedures named CHILD1 and CHILD2. You now
create a third procedure by executing: Mark for Review
(1) Points
CREATE OR REPLACE PROCEDURE parent IS
BEGIN
child1;
child2;
END;
You now want user JOE to be able to invoke PARENT. Which of the following
gives JOE the privileges he needs, but no unnecessary privileges?
(*)
GRANT EXECUTE ON * TO joe;
GRANT EXECUTE ON parent TO joe WITH ADMIN OPTION;
GRANT EXECUTE ON parent TO joe;
GRANT EXECUTE ON child1 TO joe;
GRANT EXECUTE ON child2 TO joe;
8. JOHN and FRED are database users. JOHN grants SELECT privilege to FRED
on three of his (JOHN's) tables. Which Dictionary view should FRED query to Mark for Review
see the names of JOHN's three tables? (1) Points
DBA_TABLES
DICTIONARY
ALL_TABLES (*)
USER_TABLES
FRED_TABLES
Correct
10. You want to find out how many Dictionary views will list objects in your
schema (but not in other users' schemas). Which of the following queries Mark for Review
should you use to do this? (1) Points
SELECT COUNT(*)
FROM DICTIONARY;
SELECT COUNT(*)
FROM DICTIONARY
WHERE TABLE_NAME LIKE 'USER%';
(*)
SELECT COUNT(*)
FROM DICTIONARY
WHERE TABLE_NAME NOT LIKE 'DBA%';
SELECT COUNT(*)
FROM DBA_OBJECTS
WHERE OWNER='USER';
SELECT COUNT(*)
FROM USER_DICTIONARY;
Correct
11. You need
to remove Mark for Review
procedure (1) Points
BADPROC
from your
schema.
What is
the
correct
syntax to
do this?
Correct
12. Which dictionary view will list all the PL/SQL subprograms in your schema?
Mark for Review
(1) Points
user_source
user_procedures
user_objects (*)
user_subprograms
user_dependencies
Correct
13. Which of the following is a legal location for a function call in a SQL statement?
(Choose 3) Mark for Review
(1) Points
Correct
SELECT upd_dept(80)
FROM dual;
SELECT upd_dept(department_id)
FROM employees;
DELETE FROM departments
WHERE department_id = upd_dept(department_id);
DELETE FROM employees
WHERE department_id = upd_dept(80);
(*)
Correct
15. User-defined functions can extend the power of SQL statements where Oracle
does not provide ready-made functions such as UPPER and LOWER. True or Mark for Review
False? (1) Points
True (*)
False
Correct
1. Which of
the Mark for Review
following (1) Points
is NOT a
benefit of
user-
defined
functions?
They can add business rules to the database and can be reused many
times.
They can do the same job as built-in system functions such as UPPER and
ROUND. (*)
They can often be used inside SQL statements.
They can be used in a WHERE clause to filter data.
Correct
They can add business rules to the database and can be reused many
times. (*)
They can often be used inside SQL statements. (*)
They can do the same job as built-in system functions such as UPPER and
ROUND.
They can be used in a WHERE clause to filter data and thereby increase
efficiency. (*)
Correct
4. Which of the following will tell you how many functions you own?
Mark for Review
(1) Points
5. JOHN and FRED are database users. JOHN grants SELECT privilege to FRED on
three of his (JOHN's) tables. Which Dictionary view should FRED query to see Mark for Review
the names of JOHN's three tables? (1) Points
DBA_TABLES
ALL_TABLES (*)
USER_TABLES
DICTIONARY
FRED_TABLES
Correct
6. User
JOHN Mark for Review
wants to (1) Points
see the
names of
all the
tables in
his
schema.
He does
NOT want
to see the
names of
any tables
in other
users'
schemas.
Which
Dictionary
view
should he
query?
DBA_TABLES
DICTIONARY
ALL_TABLES
USER_TABLES (*)
JOHN_TABLES
True
False (*)
8. You try to create a function named MYFUNC. The function does not compile
correctly because there are errors in your code. Which Dictionary view can you Mark for Review
query to see the errors? (1) Points
USER_SOURCE
USER_ERRORS (*)
USER_DEPENDENCIES
USER_COMPILES
USER_OBJECTS
Correct
9. A stored function:
Mark for Review
(1) Points
cannot be called in a SQL statement.
must have at least one IN parameter.
must return one and only one value. (*)
is called as a standalone executable statement.
Correct
10. How do you specify that you want a procedure MYPROCA to use "Definer's
Rights"? Mark for Review
(1) Points
Correct
SELECT ...
FROM
NEWEMP ... ;
Sally also
grants
EXECUTE
privilege on
the procedure
to CURLY, but
no other
privileges.
What will
happen when
Curly executes
the
procedure?
The procedure will fail because Curly does not have the EXECUTE
ANY PROCEDURE system privilege.
The procedure will execute successfully.
The procedure will fail because Curly does not have SELECT privilege
on NEWEMP.
The procedure will fail because there is no NEWEMP table in Curly's
schema. (*)
Correct
12. You granted user JOE the privilege to query the EMPLOYEES table in your
schema. Now, you want to remove this privilege from JOE. Which Mark for Review
command would you use? (1) Points
13. User DIANE owns a DEPARTMENTS table. User JOEL needs to update the
location_id column of Diane's table, but no other columns. Which SQL Mark for Review
statement should Diane execute to allow this? (1) Points
Correct
14. The following code shows the dependencies between three procedures:
Mark for Review
CREATE PROCEDURE parent (1) Points
IS BEGIN
child1;
child2;
END parent;
You now try to execute:
Correct
15. You want to see the names, modes, and data types of the formal
parameters of function MY_FUNC in your schema. How can you do this? Mark for Review
(Choose two) (1) Points
Query USER_FUNCTIONS
Query USER_SOURCE (*)
DESCRIBE my_func; (*)
Query USER_PARAMETERS
SHOW PARAMETER my_func;
Correct
1. Function DOUBLE_SAL
has been created as Mark for Review
follows: CREATE OR (1) Points
REPLACE FUNCTION
double_sal (p_salary IN
employees.salary%TYPE)
RETURN NUMBER IS
BEGIN RETURN(p_salary
* 2); END; Which of the
following calls to
DOUBLE_SAL will NOT
work?
Correct
2. A benefit of user-defined functions is that the function can accept
any SQL or PL/SQL data type. True or False? Mark for Review
(1) Points
True
False (*)
Correct
Correct
6. Which of
the Mark for Review
following (1) Points
is a
difference
between
a
procedure
and a
function?
Correct
DECLARE
v_mynum NUMBER(6,2);
v_mydate DATE;
BEGIN
... Line A
END;
Correct
8. To create a function successfully,the first step is to test the code in an
anonymous block. Mark for Review
(1) Points
True
False (*)
Correct
It is a set of tables which can be updated by any user who has the
necessary privileges.
It is an automatically managed master catalog of all the objects stored in
the database. (*)
It contains a backup copy of all the data in the database.
It contains a list of all database tables which are not in any schema.
10. You have forgotten the name of the Dictionary view USER_TABLES. Which of the
following statements is the best and quickest way to remind yourself? Mark for Review
(1) Points
(*)
Phone the database administrator.
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'DBA%TABLE%';
HELP DICTIONARY
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'USER%TAB%';
(*)
SELECT *
FROM USER_OBJECTS
WHERE table_name LIKE '%TABLE%';
SELECT *
FROM DICTIONARY
WHERE table_name LIKE 'user%table%';
12. You granted user JOE the privilege to query the EMPLOYEES table in your
schema. Now, you want to remove this privilege from JOE. Which command Mark for Review
would you use? (1) Points
ROLLBACK;
UNGRANT SELECT ON employees TO joe;
GRANT UNSELECT ON employees TO joe;
DENY SELECT ON employees TO joe;
REVOKE SELECT ON employees FROM joe; (*)
Correct
13. You have created a function called USEFUL. You want every database user to
be able to invoke the function. Which command would you use to do this? Mark for Review
(1) Points
Correct
14. Which view would you query to see the detailed code of a procedure?
Mark for Review
(1) Points
user_errors
user_procedures
user_source (*)
user_objects
user_dependencies
99 only (*)
999 only
No rows will be inserted
99 and 999
All three ro
Which
object Mark for Review
privilege (1) Points
can be
granted
on a
single
column
of a
table?
DROP
UPDATE (*)
CREATE
SELECT
DELETE
USER_SOURCE (*)
USER_OBJECTS
USER_SUBPROGRAMS
USER_PROCEDURES
None of these
Incorrect. Refer to Section 9 Lesson 4.
Users SYS (the
DBA), TOM, Mark for Review
DICK, and (1) Points
HARRY each
have an
EMPLOYEES
table in their
schemas. SYS
creates a
procedure
DICK.SEL_EMP
using Invoker's
Rights which
contains the
following
code:
SELECT ...
FROM
EMPLOYEES ...
;
HARRY now
executes the
procedure.
Which
employees
table will be
queried?
HARRY.EMPLOYEES (*)
None of these.
DICK.EMPLOYEES
SYS.EMPLOYEES
SELECT
employee_id,
tax(p_value
=> salary)
FROM
employees;
CREATE
OR
REPLACE
FUNCTION
newfunc
.... ;
What
happens?
Which of
the Mark for Review
following (1) Points
is a
benefit of
user-
defined
functions?
(Choose
3)
(Choose all correct answers)
They can be used in a WHERE clause to filter data and thereby increase
efficiency. (*)
They can do the same job as built-in system functions such as UPPER and
ROUND.
They can often be used inside SQL statements. (*)
They can add business rules to the database and can be reused many times.
(*)
The function
avg_ann_sal Mark for Review
returns the (1) Points
average annual
salary for a
particular
department. The
example below
is a valid use of
this function.
True or False?
SELECT
first_name,
last_name
FROM
employees
WHERE
avg_ann_sal(20)
> 15000;
True (*)
False
Examine the
following code: Mark for Review
(1) Points
CREATE
PROCEDURE
parent
IS BEGIN
child1;
child2;
EXCEPTION
WHEN
NO_DATA_FOUND
THEN NULL;
END parent;
Neither CHILD1
nor CHILD2 has
an exception
handler.
When PARENT is
invoked, CHILD1
raises a
NO_DATA_FOUND
exception. What
happens next?
CHILD1 ends abruptly; PARENT handles the exception and then ends; CHILD2 does not
execute. (*)
CHILD1 ends abruptly, PARENT handles the exception, and then CHILD2 executes.
PARENT handles the exception, and then CHILD1 continues to execute.
PARENT does not compile because you cannot use NULL; in an exception handler.
CHILD1 ends abruptly; PARENT also ends abruptly and returns an unhandled exception.
What is
wrong with Mark for Review
the (1) Points
following
code?
CREATE
FUNCTION
badfunc
(p_param
NUMBER(4))
RETURN
BOOLEAN
IS BEGIN
RETURN
(p_param >
10);
END
badfunc;
The datatype of the IN parameter cannot have a precision or scale. It must be NUMBER, not
NUMBER(4). (*)
The NUMBER datatype must have a scale as well as a precision.
P_PARAM must have a default value.
P_PARAM must be declared AFTER the RETURN clause.
RETURN (p_param > 10); is wrong because you cannot return an expression.
Which of
the Mark for Review
following (1) Points
is found in
a function
and not a
procedure?
IN parameters
Return statement in the header (*)
Local variables in the IS/AS section
An exception section
Incorrect. Refer to Section 9 Lesson 1.