100% found this document useful (1 vote)
1K views23 pages

Semester 2 Final Exam - Oracle Academy

The document is a test review with multiple choice questions about database triggers. It indicates that triggers can fire once for each row processed in a triggering SQL statement. A common error is using a COMMIT statement within a trigger body. Triggers automatically execute in response to events like data modifications or server errors.

Uploaded by

Ari Yanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
1K views23 pages

Semester 2 Final Exam - Oracle Academy

The document is a test review with multiple choice questions about database triggers. It indicates that triggers can fire once for each row processed in a triggering SQL statement. A common error is using a COMMIT statement within a trigger body. Triggers automatically execute in response to events like data modifications or server errors.

Uploaded by

Ari Yanto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

0000-3929-16e6-2e4b-ea8.

txt
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 13
(Answer all questions in this section)
1. The following code will successfully create emp_trigg:
True or False?
CREATE OR REPLACE TRIGGER emp_trigg
BEFORE DELETE OF salary ON employees
BEGIN
RAISE_APPLICATION_ERROR(-20202,'Deleting salary is not allowed');
END;
Mark for Review
(1) Points

True

False (*)

Correct Correct

2. A DML statement trigger fires only once for each


triggering DML statement, while a row trigger fires once for each row processed
by the triggering statement. True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

3. What is wrong with the following code?


CREATE OR REPLACE TRIGGER mytrigg
AFTER DELETE ON departments
BEGIN
INSERT INTO audit_table (who, when)
VALUES (USER, SYSDATE);
COMMIT;
END;
Mark for Review
(1) Points

第 1 页
0000-3929-16e6-2e4b-ea8.txt
The last line of code should be END mytrigg;

The second line should be: AFTER DELETE OF DEPARTMENTS

A DML trigger cannot itself contain a DML statement such as INSERT INTO
audit_table.

Nothing is wrong, the trigger will execute successfully.

You cannot use COMMIT inside a trigger. (*)

Correct Correct

4. Which of the following is the correct syntax for


creating a DML trigger associated with the EMPLOYEES table? The trigger must
fire whenever an employee's JOB_ID is updated, but not if a different column is
updated. Mark for Review
(1) Points

CREATE TRIGGER job_upd_trigg


WHENEVER UPDATE OF job_id IN employees
BEGIN ...

CREATE TRIGGER job_upd_trigg


AFTER UPDATE ON employees(job_id)
BEGIN ...

CREATE TRIGGER job_upd_trigg


AFTER UPDATE ON employees.job_id
BEGIN ...

CREATE TRIGGER job_upd_trigg


AFTER UPDATE OF job_id ON employees
BEGIN ...
(*)

Correct Correct

5. There are five employees in department 50. A statement


trigger is created by:
CREATE OR REPLACE TRIGGER emp_upd_trigg
第 2 页
0000-3929-16e6-2e4b-ea8.txt
AFTER DELETE ON EMPLOYEES
BEGIN ...
A user now executes:
DELETE FROM employees WHERE department_id = 50;

How many times will the trigger fire, and when?


Mark for Review
(1) Points

Once, before the DELETE is executed

The trigger will not fire at all.

Once, after the DELETE is executed (*)

Six times, once after each row and once at the end of the statement

Five times, after each employee row is deleted

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 13
(Answer all questions in this section)
6. You can code COMMIT and ROLLBACK statements in a trigger
body. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

7. A trigger can be a public subprogram within a PL/SQL


package. True or False? Mark for Review
(1) Points

第 3 页
0000-3929-16e6-2e4b-ea8.txt

True

False (*)

Correct Correct

8. A user's schema contains procedure MYPROC, function


MYFUNC, trigger MYTRIGG and package MYPACK which contains a public procedure
PACKPROC. These subprograms have no parameters, and the function returns a
NUMBER. Which of the following calls to these objects (from an anonymous block)
are incorrect? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)

mytrigg; (*)

v_number := myfunc;

myproc;

IF NOT myfunc THEN ... (*)

mypack.packproc;

Correct Correct

9. While editing a document in Microsoft Word, you go to


the FILE menu and SAVE your work. To do this, Microsoft Word has executed an
application trigger. True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

第 4 页
0000-3929-16e6-2e4b-ea8.txt
10. Which of the following best describes a database
trigger? Mark for Review
(1) Points

A PL/SQL subprogram that executes automatically whenever an associated


database event occurs (*)

A PL/SQL subprogram that always returns exactly one value

A subprogram that is invoked explicitly by the calling application

A subprogram that checks whether a user has typed the correct password
to log on to the database

A PL/SQL subprogram that inserts rows into a logging table

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 13
(Answer all questions in this section)

11. Which of the following are good guidelines to follow


when creating a database trigger? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)

Do not create a trigger that automatically fires another trigger. (*)

Use triggers to override privilege checking and view other users'


private tables.

Do not use a trigger to replace or duplicate something which the Oracle


Server does automatically. (*)

Use triggers to prevent unauthorized users from SELECTing confidential


data.

Where possible, use a trigger to enforce a foreign key constraint.

第 5 页
0000-3929-16e6-2e4b-ea8.txt

Correct Correct

12. The database administrator creates a trigger that


automatically disconnects user HACKER whenever HACKER connects to the database.
What type of trigger is this? Mark for Review
(1) Points

A DML trigger

A Database Event trigger (*)

An INSTEAD OF trigger

A DDL trigger

A statement trigger

Correct Correct

13. What is wrong with the following code?


CREATE OR REPLACE TRIGGER call_trigg
AFTER UPDATE OR DELETE ON employees
BEGIN
CALL del_emp_proc
END;
Mark for Review
(1) Points

You cannot use a CALL statement in a DML trigger.

When using CALL, only one DML statement can be tested, so UPDATE OR
DELETE is wrong.

The CALL statement should end with a semicolon (;)

When CALL is used, the BEGIN and END; statements should be omitted. (*)

Correct Correct

第 6 页
0000-3929-16e6-2e4b-ea8.txt

14. You can create a trigger which prevents DDL statements


on an individual table, while still allowing DDL on other tables in the same
schema. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

15. The database administrator wants to write a log record


every time an Oracle Server error occurs in any user's session. The DBA creates
the following trigger:
CREATE TRIGGER log_errs_trigg
-- Line A
BEGIN
INSERT INTO errlog_table VALUES (...);
END;
What should the DBA code at Line A ?
Mark for Review
(1) Points

AFTER ORACLE ERROR ON SCHEMA

AFTER ERROR ON DATABASE

AFTER SERVERERROR ON DATABASE (*)

AFTER SERVERERROR ON SCHEMA

AFTER SERVER ERROR ON DATABASE

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.

Section 13
(Answer all questions in this section)

第 7 页
0000-3929-16e6-2e4b-ea8.txt
16. A trigger automatically inserts a row into a logging
table every time a user's session receives this error message:
ORA-00942: table or view does not exist
What kind of trigger is this? Mark for Review
(1) Points

A row trigger

A statement trigger

A DDL trigger

A database event trigger (*)

An AFTER trigger

Correct Correct

17. There are 3 employees in department 90 and 5 employees


in department 50. The following trigger has been created:
CREATE TRIGGER upd_emp_trigg
AFTER UPDATE ON employees
FOR EACH ROW
BEGIN
...
A user now executes:
UPDATE employees
SET department_id = 50
WHERE department_id = 90;
How many times will the trigger fire?

Mark for Review


(1) Points

Once

Three times (*)

Four times

Five times
第 8 页
0000-3929-16e6-2e4b-ea8.txt

Eight times

Correct Correct

18. Which of the following can NOT be coded in the body of a


DML trigger? (Choose two.) Mark for Review
(1) Points

(Choose all correct answers)

IF SELECTING THEN (*)

IF DELETING THEN

IF INSERTING THEN

IF UPDATING ('JOB_ID') THEN

IF OTHERS THEN (*)

Correct Correct

19. What are the timing events for a compound trigger?


Mark for Review
(1) Points

Before the triggering statement; Before each row; After each row; After
the triggering statement (*)

Before the triggering statement; Before each row; After the triggering
statement

Before the triggering statement; After the triggering statement; Instead


of the triggering statement

Before the triggering statement; After the triggering statement; After


each row

第 9 页
0000-3929-16e6-2e4b-ea8.txt

Correct Correct

20. Whenever an employee's JOB_ID is updated, we want to


insert a row into a logging table to record the employee_id and the new value of
JOB_ID. We create a row trigger whose body includes the following code:
BEGIN
INSERT INTO logging_table (emp_id, job_id)
VALUES -- Point A
END;
At point A, which of the following will insert the correct data into the logging
table? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)

(:OLD.employee_id, :OLD.job_id);

(:NEW.employee_id, :OLD.job_id);

(:NEW.employee_id, :NEW.job_id); (*)

(:OLD.employee_id, :NEW.job_id); (*)

(NEW.employee_id, NEW.job_id);

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 13
(Answer all questions in this section)

21. Which of the following statements about INSTEAD OF


triggers are NOT true? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)

They can be created on a table. (*)

第 10 页
0000-3929-16e6-2e4b-ea8.txt
They can be created on a simple view.

They can be row triggers.

They can be created on a complex view.

They can be statement triggers. (*)

Correct Correct

22. What is wrong with this compound trigger example?


CREATE OR REPLACE TRIGGER compound_trigger
FOR UPDATE OF salary
COMPOUND TRIGGER
threshold CONSTANT SIMPLE_INTEGER := 200;
BEFORE EACH ROW IS
BEGIN
-- some action
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN
-- some action
END AFTER EACH ROW;

AFTER STATEMENT IS
BEGIN
-- some action
END AFTER STATEMENT;
END compound_trigger;
Mark for Review
(1) Points

Missing BEFORE timing statement

Missing the EXCEPTION section

Missing name of table on which the trigger fires (*)

Missing the INSTEAD OF timing section

Missing the BEFORE and INSTEAD OF timing sections

第 11 页
0000-3929-16e6-2e4b-ea8.txt

Correct Correct

23. You have created several DML triggers which reference


your DEPARTMENTS table. Now you want to disable all of them using a single SQL
statement. Which command should you use? Mark for Review
(1) Points

ALTER TRIGGER DISABLE ALL ON departments;

ALTER TABLE departments DISABLE TRIGGERS;

DROP ALL TRIGGERS ON departments;

ALTER TABLE departments DISABLE ALL TRIGGERS; (*)

Correct Correct

24. By default, any user can create a DML trigger on a table


in his/her schema. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

25. You can see trigger information in the following Data


Dictionary views except: Mark for Review
(1) Points

USER_SOURCE (*)

You can view trigger information in all of these Data Dictionary views.

USER_TRIGGERS

USER_ERRORS
第 12 页
0000-3929-16e6-2e4b-ea8.txt

USER_OBJECTS

Incorrect Incorrect. Refer to Section 13 Lesson 5.


Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 14
(Answer all questions in this section)
26. A cursor's state is defined only by whether it is open
or closed and, if open, how many rows it holds. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

27. A package's state is initialized when the package is


first loaded. True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

28. Users A and B call the same procedure in a package to


initialize a global variable my_pkg.g_var. What will be the value of
my_pkg.g_var for User A at Point A?
User A: my_pkg.g_var is 10
User B: my_pkg.g_var is 10
User A: my_pkg.g_var is 50
User B: my_pkg.g_var is 25
Point A
Mark for Review
第 13 页
0000-3929-16e6-2e4b-ea8.txt
(1) Points

25

10

50 (*)

Correct Correct

29. Package MULTIPACK declares the following global


variable:
g_myvar NUMBER;
User DICK executes the following:
multipack.g_myvar := 45;
User HAZEL now connects to the database. Both users immediately execute:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
What values will Dick and Hazel see?
Mark for Review
(1) Points

Both queries will fail because the syntax of DBMS_OUTPUT.PUT_LINE is


incorrect

Dick: 45, Hazel: 45

Dick: 45, Hazel: 0

Dick: 45, Hazel: null (*)

Dick: 0, Hazel: 0

Correct Correct

30. A cursor is declared in a package specification. User


SIOBHAN opens the cursor and fetches the first three rows from the cursor's
第 14 页
0000-3929-16e6-2e4b-ea8.txt
active set, but does not close the cursor.
User FRED now connects to the database. FRED can immediately fetch the next
three rows without opening the cursor. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 14
(Answer all questions in this section)
31. Package CURSPACK declares a global cursor in the package
specification. The package contains three public procedures: OPENPROC opens the
cursor; FETCHPROC fetches 5 rows from the cursor's active set; CLOSEPROC closes
the cursor.
What will happen when a user session executes the following commands in the
order shown?
curspack.openproc; -- line 1
curspack.fetchproc; -- line 2
curspack.fetchproc; -- line 3
curspack.openproc; -- line 4
curspack.fetchproc; -- line 5
curspack.closeproc; -- line 6
Mark for Review
(1) Points

An error will occur at line 2.

An error will occur at line 4. (*)

The first 5 rows will be fetched three times.

The first 10 rows will be fetched, then the first 5 rows will be fetched
again.

The first 15 rows will be fetched.

Correct Correct
第 15 页
0000-3929-16e6-2e4b-ea8.txt

32. In the following example, which statement best fits in


Line 1? (Choose 1)
DECLARE
v_more_rows_exist BOOLEAN := TRUE;
BEGIN
-- Line 1
LOOP
v_more_rows_exist := curs_pkg.fetch_n_rows(3);
DBMS_OUTPUT.PUT_LINE('-------');
EXIT WHEN NOT v_more_rows_exist;
END LOOP;
curs_pkg.close_curs;
END;
Mark for Review
(1) Points

curs_pkg.close_curs;

EXIT WHEN curs_pkg.emp_curs%NOTFOUND;

curs_pkg.emp_curs%ISOPEN;

curs_pkg.open_curs; (*)

Correct Correct

33. When a user session changes the value of a package


variable, the new value can immediately be seen by other sessions. True or
False? Mark for Review
(1) Points

True

False (*)

Correct Correct

34. Which of the following best describes the purpose of the


UTL_FILE package? Mark for Review
(1) Points

第 16 页
0000-3929-16e6-2e4b-ea8.txt
It is used to load binary files such as employees' photos into the
database.

It is used to find out how much free space is left on an operating


system disk.

It is used to read and write text files stored outside the database. (*)

It is used to query CHAR and VARCHAR2 columns in tables.

Correct Correct

35. What will be displayed when the following code is


executed?
BEGIN
DBMS_OUTPUT.PUT('I do like');
DBMS_OUTPUT.PUT_LINE('to be');
DBMS_OUTPUT.PUT('beside the seaside');
END;
Mark for Review
(1) Points

I do like to be

I do like to be beside the seaside

I do like
to be
beside the seaside

I do like to be
beside the seaside

I do liketo be(*)

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 14
第 17 页
0000-3929-16e6-2e4b-ea8.txt
(Answer all questions in this section)
36. Using the FOPEN function, you can do which actions with
the UTL_FILE package? (Choose 2) Mark for Review
(1) Points
(Choose all correct answers)

It is used to manipulate large object data type items in columns.

It is used to read and write text files stored outside the database. (*)

It is used to append to a file until processing is complete. (*)

It is used to find out how much free space is left on an operating


system disk.

Correct Correct

37. The UTL_FILE package can be used to create binary files


such as JPEGs as well as text files. True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

38. The UTL_MAIL package allows sending email from the


Oracle database to remote recipients. Mark for Review
(1) Points

True (*)

False

Correct Correct

第 18 页
0000-3929-16e6-2e4b-ea8.txt

Section 15
(Answer all questions in this section)
39. What are the two methods for obfuscating PL/SQL
subprograms? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)

SQL wrapper utility program

PL/SQL wrapper utility program (*)

DBMS_DDL.CREATE_WRAPPED (*)

DBMS_DML.CREATE_WRAPPED

DBMS_DDL.WRAP

Correct Correct

40. When wrapping subprograms, the entire PL/SQL code must


be included as an IN argument with data type VARCHAR2 up to 32,767 characters.
True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

Test: Semester 2 Final Exam


Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 15
(Answer all questions in this section)

41. When wrapping subprograms, the entire PL/SQL code must


be included as an IN argument with data type CLOB to allow for any size program.
True or False? Mark for Review
第 19 页
0000-3929-16e6-2e4b-ea8.txt
(1) Points

True

False (*)

Correct Correct

42. To determine the current setting for


PLSQL_OPTIMIZE_LEVEL, query the data dictionary view
USER_PLSQL_OBJECTS_SETTINGS. True or False? Mark for Review
(1) Points

True (*)

False

Incorrect Incorrect. Refer to Section 15 Lesson 1.

43. PLSQL_CODE_TYPE determines the type of code for both


PL/SQL code and for SQL statements, which is what speeds up the execution speed.
True or False? Mark for Review
(1) Points

True

False (*)

Correct Correct

44. When setting PLSQL_OPTIMIZE_LEVEL = 3, the compiled code


will run more slowly, but it will work with older versions of the Oracle
software. True or False? Mark for Review
(1) Points

True

False (*)

第 20 页
0000-3929-16e6-2e4b-ea8.txt

Correct Correct

45. Conditional Compilation allows you to include some


source code in your PL/SQL program that may be compiled or may be ignored
depending on: Mark for Review
(1) Points

The version of the Oracle software you are using.

Any of these could be used. (*)

The values of an initialization parameter.

The value of a global package constant.

Correct Correct
Test: Semester 2 Final Exam
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Section 15
(Answer all questions in this section)
46. How would you determine the current Oracle database
version? Mark for Review
(1) Points

DBMS_DB_VERSION.VER_LE_10

DBMS_DB_VERSION.VERSION (*)

DBMS_DB_VERSION.RELEASE

DBMS_DB_VERSION.VER_LE_11

Correct Correct

47. In the following example, what statement belongs in Line


A?
第 21 页
0000-3929-16e6-2e4b-ea8.txt
ALTER SESSION SET PLSQL_CCFLAGS = 'debug:true';
CREATE OR REPLACE PROCEDURE testproc IS BEGIN
...
$IF $$debug $THEN
DBMS_OUTPUT.PUT_LINE('This code was executed');
-- Line A
...
END testproc;
ALTER SESSION SET PLSQL_CCFLAGS = 'debug:false';
Mark for Review
(1) Points

$$END;

$END;

$ELSIF

$ENDIF

$END (*)

Correct Correct

48. Which pair of DBMS_WARNING commands would allow you to


obtain the current settings and change and restore those settings in a PL/SQL
subprogram? (Choose two) Mark for Review
(1) Points
(Choose all correct answers)

DBMS_WARNING.SET_WARNING_SETTING_STRING (*)

DBMS_WARNING.GET_WARNING_SETTING_STRING (*)

DBMS_WARNING.ADD_WARNING_SETTING_CAT

DBMS_WARNING.GET_WARNING_STRING

第 22 页
0000-3929-16e6-2e4b-ea8.txt
Correct Correct

49. In the USER_ERRORS data dictionary view, if an error is


prefixed with "Warning," the command completes but has a side effect the user
needs to know about. For all other errors, the command terminates abnormally.
True or False? Mark for Review
(1) Points

True (*)

False

Correct Correct

50. Which term best describes the action below:


A PL/SQL program compiles successfully, but contains some code that causes
performance to be less than optimal.
Mark for Review
(1) Points

Error

Warning (*)

Correct Correct

第 23 页

You might also like