Professional Documents
Culture Documents
False
Correct
2. Which one of the following can NOT be part of a Package ? Mark for
Review
(1) Points
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct
3. Which part of a package must be created first, the specification or the body?
Mark for Review
(1) Points
The body
The body can be created first, but only if the package has no specification.
Correct
4. Package MYPACK contains procedure MYPROC. You can see which
parameters MYPROC uses by executing: DESCRIBE mypack.myproc. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
5. Examine the following code:
Correct
6. Which two of these declarations cannot be in the same package specification?
1 and 3 (*)
2 and 3
3 and 4
1 and 4
Correct
7. We never need to use a forward declaration when invoking a public
subprogram. True or False? Mark for Review
(1) Points
True (*)
False
Correct
8. Examine the following package code:
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
SAVEPOINT
ALTER (*)
GRANT (*)
Correct
10. You want to create a function which drops a table. You write the following
code:
Because the PL/SQL compiler cannot check if the argument of p_tab_name is a valid
table-name (*)
Correct
Section 9 11. A SQL statement can pass through several stages. Which of the
following is NOT one of these stages? Mark for Review
(1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
Correct
12. Examine the following code:
The procedure will not compile successfully because the syntax of EXECUTE
IMMEDIATE is incorrect.
The procedure will raise an exception because Dynamic SQL can drop tables but
cannot drop views.
The procedure will raise an exception because one of the views is a complex view.
Correct
13. We need to declare a package variable named MYVAR, which can be
referenced by any subprogram in the package but can NOT be referenced from outside the
package. In the following code, where should MYVAR be declared?
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
-- Point B
PROCEDURE varproc IS
-- Point C
BEGIN
END varproc;
PROCEDURE ...
-- Point D
END varpack;
Point B (*)
Point C
Point D
Correct
14. Examine the following package specification:
The package body of TAXPACK also includes a function called TAXFUNC. Which one of
the following statements is NOT true?
Mark for Review
(1) Points
The procedure can be invoked by:
BEGIN
taxpack.taxproc;
END;
The packaage will not compile because you cannot declare a cursor in the
specification.
(*)
Correct
15. A package contains both public and private subprograms. Which one of the
following statements is true? Mark for Review
(1) Points
Each subprogram is loaded into memory when it is first invoked.
The public subprograms are all loaded into memory at the same time, but the private
subprograms are loaded into memory one at a time as they are invoked.
The whole package is loaded into memory when the first call is made to any
subprogram in the package. (*)
If three users invoke three different subprograms in the package, there will be three
copies of the code in memory.
Correct
16. In a package, public components are declared in the specification but private
components are not. True or False? Mark for Review
(1) Points
True (*)
False
Correct
17. Your schema contains four packages, each having a specification and a
body. You have also been granted privileges to access three packages (and their bodies) in
other users' schemas. What will be displayed by the following query?
6 (*)
Correct
18. Package OLDPACK is in your schema. What will happen when the
following statement is executed?
The specification will be dropped but the body will be retained. Both
The statement will fail because you must drop the body before you can drop the
specification.
Correct
19. When a change is made to the detailed code of a public procedure in a
package (but not to the procedure's name or parameters), both the specification and the
body must be recompiled. True or False? Mark for Review
(1) Points
True
False (*)
False
Correct
Section 9 21. 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
22. Which of the following exceptions can be raised ONLY when using the
UTL_FILE package? (Choose two) Mark for Review
(1) Points (Choose all correct answers)
INVALID_PATH (*)
NO_DATA_FOUND
VALUE_ERROR
READ_ERROR (*)
E_MYEXCEP
Correct
23. 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
beside the seaside
I do like
to be
beside the seaside
I do like to be
I do liketo be
(*)
False (*)
Correct
25. Package MULTIPACK declares the following global variable:
g_myvar NUMBER;
User HAZEL now connects to the database. Both users immediately execute:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
Dick: 0, Hazel: 0
UPDATE('LAST_NAME') THEN
IF UPDATING THEN
Correct
27. Examine the following code. To create a row trigger, what code should be
included at Line A?
ON EACH ROW
ON EVERY ROW
Correct
28. 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 DELETING THEN
IF INSERTING THEN
Correct
29. In the following code:
False (*)
Correct
30. User AYSEGUL successfully creates the following trigger:
Both the table and the trigger are dropped. (*) None
of the above.
Correct
Section 10 31. MARY and JOE's schemas each contain an EMPLOYEES table.
JOE creates the following trigger:
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What object
privileges will TOM and JOE need?
Correct
32. Which of the following will remove a trigger in your schema named
EMP_TRIGG from the database? Mark for Review
(1) Points
DROP emp_trigg TRIGGER;
Correct
33. Examine the following code:
Correct
34. Which of the following statements could cause a DDL trigger to fire?
Mark for Review
(1) Points
DROP TABLE employees;
Correct
35. You want to prevent any objects in your schema from being altered or
dropped. You decide to create the following trigger:
Correct
37. Examine this code:
SCHEMA (*)
USER
DATABASE (*)
TABLE employees
Correct
38. 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
An AFTER trigger
Correct
39. 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:
Correct
40. Examine the following code:
CREATE TRIGGER emp_trigg
-- Line A
BEGIN
INSERT INTO log_table VALUES (USER, SYSDATE);
END;
Correct
Section 10 41. What is wrong with the following code?
(*)
Correct
42. You need to create a trigger that will fire whenever an employee's salary or
job_id is updated, but not when any other column of the EMPLOYEES table is updated.
Which of the following is the correct syntax to do this? Mark for Review
(1) Points
CREATE TRIGGER emp_upd_trigg
AFTER UPDATE ON employees (salary, job_id)
BEGIN ...
(*)
Correct
43. The following code will successfully create emp_trigg: True or False?
False (*)
Correct
44. 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)
Where possible, use a trigger to enforce a foreign key constraint.
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. (*)
Correct
45. You can code COMMIT and ROLLBACK statements in a trigger body.
True or False? Mark for Review
(1) Points
True
False (*)
Correct
46. A trigger can be created in the database or within an application. True or
False? Mark for Review
(1) Points
True (*)
False
Correct
47. What type of database object would you create to write an auditing record
automatically every time a user connects to the database? Mark for Review
(1) Points
A procedure
A complex view
A trigger (*)
A function
A package
Correct
48. Which of the following best describes a database trigger? Mark for
Review
(1) Points
A subprogram that checks whether a user has typed the correct password to log on to
the database.
Correct
49. A trigger can be a public subprogram within a PL/SQL package. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
50. A business rule states that an employee's salary cannot be greater than
99,999.99 or less than 0. The best way to enforce this rule is by using: Mark for
Review
(1) Points
A datatype of NUMBER(7,2) for the SALARY column
A database trigger
An application trigger
A view
Correct
Mid Term Exam Semester 2
Correct
Correct
Correct
DDL triggers
AFTER DELETE row triggers (*)
INSTEAD OF triggers
TABLE
SCHEMA (*)
USER
DATABASE (*)
TABLE employees
Correct
Which of the following are NOT valid at Line A ? (Choose two.) Mark
for Review
(1) Points
Correct
8. You need to disable all triggers that are associated
with DML statements on the DEPARTMENTS table. Which of the following
commands should you use? Mark for Review
(1) Points
Correct
True (*)
False
AYSEGUL now tries to drop the LOCATIONS table. What happens? Mark for
Review
(1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
Correct
What will happen when this procedure is invoked? Mark for Review
(1) Points
SAVEPOINT
ALTER (*)
GRANT (*)
Correct
DECLARE
v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := 'GRANT SELECT ON employees TO henry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
True
False (*)
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
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
Correct
Correct
18. A public function in a package is invoked from within a
SQL statement. The function's code can include a COMMIT statement. True or
False? Mark for Review
(1) Points
True
False (*)
Correct
(*)
Correct
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
database trigger
A sequence
22. You can use a trigger to prevent rows from being deleted
from the EMPLOYEES table on Mondays. True or False? Mark for Review
(1) Points
True (*)
False
Correct
A procedure
A complex view
A trigger (*)
A function
A package
Correct
A database trigger
An application trigger
A view
Correct
pack1.packproc(25); (*)
trigg1;
True
False (*)
Correct
False
Correct
UTL_FILE.CREATE('FILESDIR','EMP_REPORT.TXT');
UTL_FILE.FOPEN('C:\NEWFILES\EMP_REPORT.TXT','w');
UTL_FILE.FOPEN('FILESDIR','EMP_REPORT.TXT','w'); (*)
UTL_FILE.OPEN('FILESDIR','EMP_REPORT.TXT','c');
Correct
Correct
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
beside the seaside
I do like
to be
beside the seaside
I do like to be
I do liketo be
(*)
True (*)
False
mypack.myfunc('22-JAN-07');
mypack.myproc(35);
(*)
(*)
myproc(40);
v_num := mypack.myproc(22);
Correct
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct
(*)
(*)
(*)
True (*)
False
Correct
False (*)
True (*)
False
Correct
(*)
Correct
Correct
True
False (*)
Correct
14
6 (*)
Correct
ON EACH ROW
ON EVERY ROW
Correct
48. With which kind of trigger can the :OLD and :NEW
qualifiers be used? Mark for Review
(1) Points
DDL triggers
Statement triggers
AFTER triggers
Correct
True
False (*)
IF UPDATE('LAST_NAME') THEN
IF UPDATING THEN
Correct
Mid Term Exam Semester 2
(*)
Which of the following can NOT be coded at Line A? Mark for Review
(1) Points
(*)
(*)
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
mypack.myfunc('22-JAN-07');
mypack.myproc(35);
(*)
(*)
myproc(40);
v_num := mypack.myproc(22);
Correct
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
DELETE
SAVEPOINT
ALTER (*)
SELECT ..... FOR UPDATE NOWAIT
GRANT (*)
Which of the following will work correctly when coded at line A? (Choose
two.) Mark for Review
(1) Points
v_first_string || p_col_name ||
v_second_string;
(*)
v_first_string := v_first_string ||
p_col_name;
EXECUTE IMMEDIATE v_first_string || v_second_string;
(*)
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
Why will this procedure not compile successfully? Mark for Review
(1) Points
Correct
True
False (*)
Correct
Correct
17. Your schema contains four packages, each having a
specification and a body. You have also been granted privileges to access
three packages (and their bodies) in other users' schemas. What will be
displayed by the following query?
14
6 (*)
BEGIN
taxpack.taxproc;
END;
(*)
(*)
True
False (*)
True
False (*)
Correct
Which of the following are NOT valid at Line A ? (Choose two.) Mark
for Review
(1) Points
DDL triggers
INSTEAD OF triggers
TABLE
SCHEMA (*)
USER
DATABASE (*)
TABLE employees
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What
object privileges will TOM and JOE need? Mark for Review
(1) Points
AYSEGUL now tries to drop the LOCATIONS table. What happens? Mark for
Review
(1) Points
True
False (*)
Correct
True (*)
False
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
True
False (*)
Correct
A procedure
A complex view
A trigger (*)
A function
A package
Correct
38. You can use a trigger to prevent rows from being deleted
from the EMPLOYEES table on Mondays. True or False? Mark for Review
(1) Points
True (*)
False
Correct
True (*)
False
True
False (*)
A database trigger
An application trigger
A view
Correct
True (*)
False
Correct
True (*)
False
Correct46. An Oracle directory
called FILESDIR has been created by executing:
CREATE OR REPLACE DIRECTORY filesdir AS 'C:\NEWFILES';
Which of the following will create a new text file called
C:\NEWFILES\EMP_REPORT.TXT ? Mark for Review
(1) Points
UTL_FILE.CREATE('FILESDIR','EMP_REPORT.TXT');
UTL_FILE.FOPEN('C:\NEWFILES\EMP_REPORT.TXT','w');
UTL_FILE.FOPEN('FILESDIR','EMP_REPORT.TXT','w'); (*)
UTL_FILE.OPEN('FILESDIR','EMP_REPORT.TXT','c');
ON EACH ROW
ON EVERY ROW
IF UPDATE('LAST_NAME') THEN
IF UPDATING THEN
How many times will the trigger fire? Mark for Review
(1) Points
Once
Four times
Five times
Eight times
50. With which kind of trigger can the :OLD and :NEW
qualifiers be used? Mark for Review
(1) Points
DDL triggers
Statement triggers
AFTER triggers
Incorrect. Refer to Section 10.
Test: Mid Term Exam Semester 2
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
True
False (*)
Correct
Correct
The procedure will raise an exception because Dynamic SQL can drop
tables but cannot drop views.
Correct
5. INSTEAD OF triggers are always row triggers, even if FOR EACH ROW is
omitted. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
6. Examine the following code. To create a row trigger, what code should
be included at Line A?
CREATE TRIGGER dept_trigg
AFTER UPDATE OR DELETE ON departments
-- Line A
BEGIN ...
ON EACH ROW
ON EVERY ROW
Correct
7. Which of the following can NOT be coded in the body of a DML trigger?
(Choose two.) Mark for Review
(1) Points
IF DELETING THEN
IF INSERTING THEN
8. With which kind of trigger can the :OLD and :NEW qualifiers be used?
Mark for Review
(1) Points
DDL triggers
Statement triggers
AFTER triggers
Correct
Correct
Page 2 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
A row trigger
A statement trigger
A DDL trigger
An AFTER trigger
Correct
12. What is the purpose of using the CALL statement in a trigger? Mark
for Review
(1) Points
It allows both DML events and DDL events to be handled using a single
trigger.
Correct
13. You want to prevent any objects in your schema from being altered or
dropped. You decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
Correct
14. Which of the following statements could cause a DDL trigger to fire?
Mark for Review
(1) Points
Correct
Correct
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
True (*)
False
Correct
17. We want to remove the specification (but not the body) of package
BIGPACK from the database. Which of the following commands will do this?
Mark for Review
(1) Points
Correct
The package body of TAXPACK also includes a function called TAXFUNC. Which
one of the following statements is NOT true?
Mark for Review
(1) Points
The packaage will not compile because you cannot declare a cursor in
the specification.
(*)
19. Which of the following will display the detailed code of the
subprograms in package DEPTPACK in your schema ? Mark for Review
(1) Points
Correct
20. A package contains both public and private subprograms. Which one of
the following statements is true? Mark for Review
(1) Points
The public subprograms are all loaded into memory at the same time, but
the private subprograms are loaded into memory one at a time as they are
invoked.
The whole package is loaded into memory when the first call is made to any
subprogram in the package. (*)
Correct
Page 4 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
21. Package OLDPACK is in your schema. What will happen when the
following statement is executed?
DROP PACKAGE oldpack;
Mark for Review
(1) Points
The body will be dropped but the specification will be retained. The
Correct
22. Your schema contains four packages, each having a specification and a
body. You have also been granted privileges to access three packages (and their
bodies) in other users' schemas. What will be displayed by the
following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE 'PACK%'
AND owner <> USER;
14
6 (*)
The first 10 rows will be fetched, then the first 5 rows will be
fetched again.
Correct
24. 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 (*)
True (*)
False
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
26. You can use a trigger to prevent rows from being deleted from the
EMPLOYEES table on Mondays. True or False? Mark for Review
(1) Points
True (*)
False
27. What type of database object would you create to write an auditing
record automatically every time a user connects to the database? Mark for
Review
(1) Points
A procedure
A complex view
A trigger (*)
A function
A package
Correct
True
False (*)
Correct
29. Which of the following are NOT stored inside the database? (Choose
two.) Mark for Review
(1) Points
A database trigger
A sequence
30. Which of the following best describes a database trigger? Mark for
Review
(1) Points
A subprogram that checks whether a user has typed the correct password
to log on to the database.
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
A database trigger
An application trigger
A view
FUNCTION sal_ok;
Correct
True
False (*)
The SELECT will fail because you cannot return SQL%ROWCOUNT from a
packaged function.
The SELECT will fail because you cannot call packaged functions from
within a SQL statement.
The SELECT will fail because you cannot execute a DML statement from
within a query.
True (*)
False
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Correct
37. MARY and JOE's schemas each contain an EMPLOYEES table. JOE creates
the following trigger:
CREATE TRIGGER upd_trigg
AFTER DELETE ON joe.employees
FOR EACH ROW
BEGIN
DELETE FROM mary.employees
WHERE employee_id = :OLD.employee_id;
END;
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What
object privileges will TOM and JOE need?
Mark for Review
(1) Points
TOM does not need any object privileges, but JOE needs DELETE on both
TOM.EMPLOYEES and MARY.EMPLOYEES
JOE does not need any object privileges, but TOM needs DELETE on
MARY.EMPLOYEES
Correct
38. Which of the following will remove a trigger in your schema named
EMP_TRIGG from the database? Mark for Review
(1) Points
Correct
39. There are five employees in department 50. The following trigger is
created:
CREATE TRIGGER upd_emp
AFTER UPDATE ON employees
BEGIN
INSERT INTO audit_table VALUES (USER, SYSDATE);
END;
One (*)
Two
Five
Six
Correct
40. 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
Page 8 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
You cannot use :NEW in a BEFORE trigger, only in an AFTER trigger. You
Correct
43. What is wrong with the following syntax for creating a package
specification?
CREATE OR REPLACE PACKAGE mypack IS
g_constant1 NUMBER(6) := 100;
FUNCTION func1 (p_param1 IN VARCHAR2);
FUNCTION func2;
END mypack;
Correct
44. Every subprogram which has been declared in a package specification
must also be included in the package body. Triue or False? Mark for Review
(1) Points
True (*)
False
Correct
45. Which one of the following can NOT be part of a Package ? Mark for
Review
(1) Points
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
46. Package MYPACK contains procedure MYPROC. You can see which
parameters MYPROC uses by executing: DESCRIBE mypack.myproc. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
47. DBMS_OUTPUT.PUT_LINE can be invoked from inside a private packaged
function. True or False? Mark for Review
(1) Points
True (*)
False
Correct
49. Which of the following best describes the purpose of the UTL_FILE
package? Mark for Review
(1) Points
It is used to read and write text files stored outside the database.
(*)
Correct
UTL_FILE.CREATE('FILESDIR','EMP_REPORT.TXT');
UTL_FILE.FOPEN('C:\NEWFILES\EMP_REPORT.TXT','w');
UTL_FILE.FOPEN('FILESDIR','EMP_REPORT.TXT','w'); (*)
UTL_FILE.OPEN('FILESDIR','EMP_REPORT.TXT','c');
Correct
Page 10 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Correct
True
False (*)
You cannot use :NEW in a BEFORE trigger, only in an AFTER trigger. You
5. Which one of the following can NOT be part of a Package ? Mark for
Review
(1) Points
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct
Page 1 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
True
False (*)
Correct
The body
Correct
mypack.myfunc('22-JAN-07');
mypack.myproc(35);
(*)
myproc(40);
v_num := mypack.myproc(22);
Correct
Correct
Page 2 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
12. What is the purpose of using the CALL statement in a trigger? Mark for
Review
(1) Points
It allows both DML events and DDL events to be handled using a single
trigger.
Correct
A row trigger
A statement trigger
A DDL trigger
An AFTER trigger
Correct
14. You want to prevent any objects in your schema from being altered or
dropped. You decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
Correct
15. Which kinds of trigger can cause a mutating table problem? (Choose
two.) Mark for Review
(1) Points
DDL triggers
INSTEAD OF triggers
Correct
Page 3 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
The procedure will raise an exception because Dynamic SQL can drop
tables but cannot drop views.
Correct
17. A SQL statement can pass through several stages. Which of the
following is NOT one of these stages? Mark for Review
(1) Points
BIND
FETCH
PARSE
RETURN (*)
EXECUTE
Correct
DELETE
SAVEPOINT
ALTER (*)
GRANT (*)
Incorrect. Refer to Section 9.
19. MARY wants HENRY to be able to query her EMPLOYEES table. Mary
executes the following code:
DECLARE
v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := 'GRANT SELECT ON employees TO henry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
Mary has successfully granted the privilege to Henry. True or False? Mark
for Review
(1) Points
True
False (*)
Correct
The first 10 rows will be fetched, then the first 5 rows will be
fetched again.
Correct
Page 4 of 10
Test: Mid Term Exam Semester 2
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
User HAZEL now connects to the database. Both users immediately execute:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
Dick: 0, Hazel: 0
True
False (*)
Correct
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
Correct
ol_pack.subprog('Jane',30);
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
The SELECT will fail because you cannot return SQL%ROWCOUNT from a
packaged function.
The SELECT will fail because you cannot call packaged functions from
within a SQL statement.
The SELECT will fail because you cannot execute a DML statement from
within a query.
Correct
Page 5 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
-- Point B
PROCEDURE varproc IS
-- Point C
BEGIN
END varproc;
PROCEDURE ...
-- Point D
END varpack;
Point A
Point B (*)
Point C
Point D
Point B or Point C, they will both work
True (*)
False
Correct
28. Package OLDPACK is in your schema. What will happen when the
following statement is executed?
DROP PACKAGE oldpack;
Mark for Review
(1) Points
The body will be dropped but the specification will be retained. The
The statement will fail because you must drop the body before you can
drop the specification.
Correct
29. A package contains both public and private subprograms. Which one of the
following statements is true? Mark for Review
(1) Points
The public subprograms are all loaded into memory at the same time, but
the private subprograms are loaded into memory one at a time as they are
invoked.
The whole package is loaded into memory when the first call is made to
any subprogram in the package. (*)
If three users invoke three different subprograms in the package, there will
be three copies of the code in memory.
Correct
30. We want to remove the specification (but not the body) of package
BIGPACK from the database. Which of the following commands will do this?
Mark for Review
(1) Points
DROP PACKAGE bigpack;
Page 6 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Correct
32. Your schema contains four packages, each having a specification and a
body. You have also been granted privileges to access three packages (and their
bodies) in other users' schemas. What will be displayed by the
following query?
SELECT COUNT(*) FROM ALL_OBJECTS
WHERE object_type LIKE 'PACK%'
AND owner <> USER;
Mark for Review
(1) Points
14
6 (*)
Correct
33. The DBMS_OUTPUT.PUT procedure places text in a buffer but does not
display the contents of the buffer. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Correct
True
False (*)
Correct
Page 7 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
I do like to be
beside the seaside
I do like
to be
beside the seaside
I do like to be
I do liketo be
(*)
37. You need to disable all triggers that are associated with DML
statements on the DEPARTMENTS table. Which of the following commands should you
use? Mark for Review
(1) Points
Correct
38. After the following SQL statement is executed, all the triggers on
the DEPARTMENTS table will no longer fire, but will remain in the database.
True or False?
ALTER TABLE departments DISABLE ALL TRIGGERS;
Mark for Review
(1) Points
True (*)
False
Correct
39. MARY and JOE's schemas each contain an EMPLOYEES table. JOE creates
the following trigger:
CREATE TRIGGER upd_trigg
AFTER DELETE ON joe.employees
FOR EACH ROW
BEGIN
DELETE FROM mary.employees
WHERE employee_id = :OLD.employee_id;
END;
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What
object privileges will TOM and JOE need?
Mark for Review
(1) Points
TOM does not need any object privileges, but JOE needs DELETE on both
TOM.EMPLOYEES and MARY.EMPLOYEES
JOE does not need any object privileges, but TOM needs DELETE on
MARY.EMPLOYEES
Correct
40. You can use a trigger to prevent rows from being deleted from the
EMPLOYEES table on Mondays. True or False? Mark for Review
(1) Points
True (*)
False
Correct
Page 8 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
True
False (*)
Correct
42. Which of the following best describes a database trigger? Mark for
Review
(1) Points
A subprogram that checks whether a user has typed the correct password
to log on to the database.
Correct
43. You can code COMMIT and ROLLBACK statements in a trigger body. True
or False? Mark for Review
(1) Points
True
False (*)
Correct
44. Which of the following are good guidelines to follow when creating a
database trigger? (Choose two.) Mark for Review
(1) Points
Correct
45. What type of database object would you create to write an auditing
record automatically every time a user connects to the database? Mark for
Review
(1) Points
A procedure
A complex view
A trigger (*)
A function
A package
Correct
Page 9 of 10
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Mid Term Exam Semester 2
A database trigger
An application trigger
A view
Correct
Once
Four times
Five times
Eight times
Correct
False (*)
49. Examine the following code. To create a row trigger, what code
should be included at Line A?
CREATE TRIGGER dept_trigg
AFTER UPDATE OR DELETE ON departments
-- Line A
BEGIN ...
ON EACH ROW
ON EVERY ROW
Correct
50. With which kind of trigger can the :OLD and :NEW qualifiers be used?
Mark for Review
(1) Points
DDL triggers
Statement triggers
AFTER triggers
Correct
Page 10 of 10
Correct Correct
USER_SOURCE
USER_TRIGGERS (*)
USER_OBJECTS
USER_DML_TRIGGERS
USER_SUBPROGRAMS
Correct Correct
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct Correct
A and B
A, B and C
A and C
A, B and D (*)
A, B, C and D
The body
Correct Correct
True (*)
False
Correct Correct
True (*)
False
Correct Correct
INVALID_PATH (*)
NO_DATA_FOUND
VALUE_ERROR
READ_ERROR (*)
E_MYEXCEP
Incorrect Incorrect
UTL_FILE.CREATE('FILESDIR','EMP_REPORT.TXT');
UTL_FILE.FOPEN('C:\NEWFILES\EMP_REPORT.TXT','w');
UTL_FILE.FOPEN('FILESDIR','EMP_REPORT.TXT','w'); (*)
UTL_FILE.OPEN('FILESDIR','EMP_REPORT.TXT','c');
Correct Correct
Correct Correct
Previous Page 10 of 10 Summary
ON EACH ROW
ON EVERY ROW
Correct Correct
True (*)
False
Correct Correct
False (*)
Correct Correct
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
The first 10 rows will be fetched, then the first 5 rows will be
fetched again.
Correct Correct
A third user TOM needs to delete rows from JOE's EMPLOYEES table. What
object privileges will TOM and JOE need?
Mark for Review
(1) Points
TOM does not need any object privileges, but JOE needs DELETE on
both TOM.EMPLOYEES and MARY.EMPLOYEES
JOE does not need any object privileges, but TOM needs DELETE on
MARY.EMPLOYEES
Correct Correct
(*)
Correct Correct
True
False (*)
Correct Correct
IF UPDATE('LAST_NAME') THEN
IF UPDATING THEN
Correct Correct
IF DELETING THEN
IF INSERTING THEN
Correct Correct
Previous Page 7 of 10 Next Summary
Correct Correct
A database trigger
A sequence
Correct Correct
A database trigger
An application trigger
A view
Correct Correct
True (*)
False
Correct Correct
One (*)
Two
Five
Six
Correct Correct
ol_pack.subprog('Jane',30);
ol_pack.subprog(param1=>'Jane',param2=>30); (*)
v_number := ol_pack.subprog(p1=>'Jane');
Correct Correct
22. Which two of these declarations cannot be in the
same package specification?
1 and 2
1 and 3 (*)
2 and 3
3 and 4
1 and 4
Correct Correct
True
False (*)
Correct Correct
Correct Correct
pack1.packproc(25); (*)
trigg1;
The statement will fail because you must drop the body before you
can drop the specification.
Correct Correct
14
6 (*)
Correct Correct
The package body of TAXPACK also includes a function called TAXFUNC. Which
one of the following statements is NOT true?
Mark for Review
(1) Points
The procedure can be invoked by:
BEGIN
taxpack.taxproc;
END;
The packaage will not compile because you cannot declare a cursor
in the specification.
(*)
Correct Correct
The SELECT will fail because you cannot return SQL%ROWCOUNT from a
packaged function.
The SELECT will fail because you cannot call packaged functions
from within a SQL statement.
The SELECT will fail because you cannot execute a DML statement
from within a query.
FUNCTION sal_ok;
Correct Correct
FETCH
PARSE
RETURN (*)
EXECUTE
Correct Correct
True
False (*)
Correct Correct
END varpack;
CREATE OR REPLACE PACKAGE BODY varpack IS
-- Point B
PROCEDURE varproc IS
-- Point C
BEGIN
END varproc;
PROCEDURE ...
-- Point D
END varpack;
Mark for Review
(1) Points
Point A
Point B (*)
Point C
Point D
Correct Correct
(*)
Correct Correct
The public subprograms are all loaded into memory at the same time, but
the private subprograms are loaded into memory one at a time as they
are invoked.
The whole package is loaded into memory when the first call is made
to any subprogram in the package. (*)
Correct Correct
Correct Correct
The procedure will raise an exception because Dynamic SQL can drop
tables but cannot drop views.
Correct Correct
Which of the following will work correctly when coded at line A? (Choose
two.)
Mark for Review
(1) Points
(*)
(*)
Correct Correct
TABLE
SCHEMA (*)
USER
DATABASE (*)
TABLE employees
Correct Correct
Correct Correct
Correct Correct
Correct Correct
DDL triggers
INSTEAD OF triggers
Correct Correct
Review your answers, feedback, and question scores below. An asterisk (*) i
ndicates a correct answer.
Section 9
1. Which of the following statements about packages is NOT true ? Mark for
Review
(1) Points
All procedures and functions must be declared in the specification. (*)
Correct
Which of the following will correctly invoke the package subprograms? (Ch
oose two.)
Mark for Review
(1) Points
(Choose all correct answers)
mypack.myfunc('22-JAN-07');
mypack.myproc(35);
(*)
myproc(40);
v_num := mypack.myproc(22);
Correct
3. Which one of the following can NOT be part of a Package ? Mark for
Review
(1) Points
Procedures
Explicit cursors
Triggers (*)
Functions
Global variables
Correct
4. What is wrong with the following syntax for creating a package specific
ation?
CREATE OR REPLACE PACKAGE mypack IS
g_constant1 NUMBER(6) := 100;
FUNCTION func1 (p_param1 IN VARCHAR2);
FUNCTION func2;
END mypack;
Mark for Review
(1) Points
You cannot declare constants in the specification.
Correct
Correct
The SELECT will fail because you cannot return SQL%ROWCOUNT from a
packaged function.
The SELECT will fail because you cannot call packaged functions from w
ithin a SQL statement.
The SELECT will fail because you cannot execute a DML statement from
within a query.
Correct
Add a private function to the package body of TAXPACK, and invoke the
function from the user session.
Correct
False
Correct
END varproc;
PROCEDURE ...
-- Point D
END varpack;
Mark for Review
(1) Points
Point A
Point B (*)
Point C
Point D
Correct
False
Correct
Page 1 of 5
Review your answers, feedback, and question scores below. An asterisk (*) i
ndicates a correct answer.
Section 9
11. We want to remove the specification (but not the body) of package
BIGPACK from the database. Which of the following commands will do this ?
Mark for Review
(1) Points
Correct
12. Which of the following will display the detailed code of the subp
rograms in package DEPTPACK in your schema ? Mark for Review
(1) Points
Correct
13. Package OLDPACK is in your schema. What will happen when the fol
lowing statement is executed?
DROP PACKAGE oldpack;
Mark for Review
(1) Points
The body will be dropped but the specification will be retained. The
specification will be dropped but the body will be retained. Both the
The statement will fail because you must drop the body before you can dro p
the specification.
Correct
14. Examine the following package specification:
CREATE OR REPLACE PACKAGE taxpack IS
CURSOR empcurs IS SELECT * FROM employees;
PROCEDURE taxproc;
END mypack;
The packaage will not compile because you cannot declare a cursor in the
specification.
(*)
Correct
Correct
16. The DBMS_OUTPUT.PUT procedure places text in a buffer but does not
display the contents of the buffer. True or False? Mark for Review
(1) Points
True (*)
False
Correct
17. Which of the following best describes the purpose of the UTL_FILE
package? Mark for Review
(1) Points
It is used to load binary files such as employees' photos into the database.
It is used to read and write text files stored outside the database. (*)
It is used to find out how much free space is left on an operating system di
sk.
Correct
18. Why is it better to use DBMS_OUTPUT only in anonymous blocks, no t
inside stored subprograms such as procedures? Mark for Review
(1) Points
Correct
19. The UTL_FILE package can be used to create binary files such as JPEG s
as well as text files. True or False? Mark for Review
(1) Points
True
False (*)
Correct
20. You want to create a function which drops a table. You write the follo
wing code:
CREATE OR REPLACE FUNCTION droptab
(p_tab_name IN VARCHAR2)
RETURN BOOLEAN IS
BEGIN
DROP TABLE p_tab_name;
RETURN TRUE;
EXCEPTION
WHEN OTHERS THEN RETURN FALSE;
END;
Correct
Page 2 of 5
Review your answers, feedback, and question scores below. An asterisk (*) i
ndicates a correct answer.
Section 9
21. MARY wants HENRY to be able to query her EMPLOYEES table. Mary
executes the following code:
DECLARE
v_grant_stmt VARCHAR2(50);
BEGIN
v_grant_stmt := 'GRANT SELECT ON employees TO henry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
Mary has successfully granted the privilege to Henry. True or False?
Mark for Review
(1) Points
True
False (*)
Correct
The procedure will raise an exception because Dynamic SQL can drop tab les
but cannot drop views.
The procedure will raise an exception because one of the views is a comp lex
view.
Correct
23. The easiest way to include DDL statements in a PL/SQL block is to use
the DBMS_SQL package. True or False? Mark for Review
(1) Points
True
False (*)
Correct
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
Dick: 45, Hazel: 45
Dick: 0, Hazel: 0
Correct
25. 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
Section 10
True
False (*)
Correct
27. INSTEAD OF triggers are always row triggers, even if FOR EACH RO W
is omitted. True or False? Mark for Review
(1) Points
True (*)
False
Correct
28. Which of the following can NOT be coded in the body of a DML trig
ger? (Choose two.) Mark for Review
(1) Points
(Choose all correct answers)
IF DELETING THEN
IF INSERTING THEN
Correct
29. With which kind of trigger can the :OLD and :NEW qualifiers be use d?
Mark for Review
(1) Points
DDL triggers
Database Event triggers
Statement triggers
AFTER triggers
Correct
30. MARY and JOE's schemas each contain an EMPLOYEES table. JOE cre
ates the following trigger:
CREATE TRIGGER upd_trigg
AFTER DELETE ON joe.employees
FOR EACH ROW
BEGIN
DELETE FROM mary.employees
WHERE employee_id = :OLD.employee_id;
END;
A third user TOM needs to delete rows from JOE's EMPLOYEES table. Wha t
object privileges will TOM and JOE need?
Mark for Review
(1) Points
TOM does not need any object privileges, but JOE needs DELE TE
on both TOM.EMPLOYEES and MARY.EMPLOYEES
JOE does not need any object privileges, but TOM needs DELETE on
MARY.EMPLOYEES
Correct
Page 3 of 5
Review your answers, feedback, and question scores below. An asterisk (*) i
ndicates a correct answer.
Section 10
31. You need to disable all triggers that are associated with DML st
atements on the DEPARTMENTS table. Which of the following commands shou ld
you use? Mark for Review
(1) Points
ALTER TABLE departments DISABLE ALL TRIGGERS; (*)
Correct
An error message is displayed because you cannot drop a table that is asso
ciated with a trigger.
The table is dropped and the trigger is disabled.
The trigger is dropped but the table is not dropped.
Both the table and the trigger are dropped. (*) None
of the above.
Correct
33. 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 follow
ing 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 ERROR ON DATABASE
AFTER SERVER ERROR ON DATABASE
Correct
34. You want to prevent any objects in your schema from being altered or
dropped. You decide to create the following trigger:
CREATE TRIGGER stop_ad_trigg
-- Line A
BEGIN
RAISE_APPLICATION_ERROR(-20203,'Invalid Operation');
END;
Correct
Correct
36. Which of the following statements could cause a DDL trigger to fire?
Mark for Review
(1) Points
DROP TABLE employees;
ALTER TABLE departments ADD (budget NUMBER(8,2));
Correct
TABLE
SCHEMA (*)
USER
DATABASE (*)
TABLE employees
Correct
38. Which kinds of trigger can cause a mutating table problem? (Choose
two.) Mark for Review
(1) Points
(Choose all correct answers)
BEFORE UPDATE row triggers (*)
DDL triggers
INSTEAD OF triggers
Correct
Correct
Page 4 of 5
Section 10
42. You need to create a trigger that will fire whenever an employee's s
alary or job_id is updated, but not when any other column of the EMPLOYEES
table is updated. Which of the following is the correct syntax to do this?
Mark for Review
(1) Points
Correct
43. The following code will successfully create emp_trigg: True or False?
True
False (*)
Correct
44. What type of database object would you create to write an auditing r
ecord automatically every time a user connects to the database? Mark for R
eview
(1) Points
A procedure
A complex view
A trigger (*)
A function
A package
Correct
pack1.packproc(25); (*)
trigg1;
Correct
46. You can use a trigger to prevent rows from being deleted from the
EMPLOYEES table on Mondays. True or False? Mark for Review
(1) Points
True (*)
False
Correct
47. Which of the following are good guidelines to follow when creating a
database trigger? (Choose two.) Mark for Review
(1) Points
Use triggers to override privilege checking and view other users' private ta
bles.
Correct
48. Which of the following are NOT stored inside the database? (Choose
two.) Mark for Review
(1) Points
(Choose all correct answers)
A PL/SQL package specification
A database trigger
A sequence
Correct
49. A business rule states that an employee's salary cannot be greater tha n
99,999.99 or less than 0. The best way to enforce this rule is by using: M ark
for Review
(1) Points
A datatype of NUMBER(7,2) for the SALARY column A
database trigger
An application trigger
A view
Correct
50. Which of the following best describes a database trigger? Mark for R
eview
(1) Points
A subprogram that checks whether a user has typed the correct password t o
log on to the database.
Correct
Page 5 of 5
Mid Term Exam Semester 2
Which statement about group functions is true?
Group functions ignore null values.
To control the order of rows returned using SET operators, the ORDER BY clause is used ______ and is placed in
the _____ SELECT statement of the query.
ONCE; LAST
When using SET operators the names of the columns must be identified in all of the SELECT statements used in
the query. True or False?
False
GROUPING SETS is another extension to the GROUP BY clause and is used to specify multiple groupings of data
but provide a single result set. True or False?
True
CUBE can be applied to all aggregate functions including AVG, SUM, MIN, MAX, and COUNT. True or False?
True
The Oracle server performs a correlated subquery when the subquery references a column from a table referred to
in the parent. True or False?
True
If a single-row subquery returns a null value and uses the equality comparison operator, what will the outer query
return?
No rows
Which of the following is a valid reason why the query below will not execute successfully?
SELECT employee_id, last_name, salary
FROM employees
WHERE department_id =
(SELECT department_id FROM employees WHERE last_name like '%u%')
Single rather than multiple value operator used.
You need to display all the players whose salaries are greater than or equal to John Brown's salary. Which
comparison operator should you use?
>=
You need to create a report to display the names of products with a cost value greater than the average cost of all
products. Which SELECT statement should you use?
SELECT product_name
FROM products
WHERE cost > (SELECT AVG(cost)
FROM product);
CLASS_ASSIGNMENTS
CLASS_ID NUMBER (5) Primary Key
TEACHER_ID NUMBER (5)
DATE
MAX_CAPACITY NUMBER (3)
All MAX_CAPACITY values are greater than 10. Which two SQL statements correctly use subqueries?
SELECT *
FROM class_assignments
WHERE max_capacity = (SELECT AVG(max_capacity) FROM class_assignments);
SELECT *
FROM teachers
WHERE teacher_id = (SELECT teacher_id FROM teachers WHERE class_id = 45963);
If you use the equality operator (=) with a subquery, how many values can the subquery return?
Only 1
You need to remove a row from the EMPLOYEES table. Which statement would you use?
DELETE with a WHERE clause
You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one
UPDATE statement. Which clause should you include in the UPDATE statement to update multiple columns?
The SET clause
What keyword in an UPDATE statement speficies the columns you want to change?
SET
PRODUCTS
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIERS table
CATEGORY_ID NUMBER
QTY_PER_UNIT NUMBER
UNIT_PRICE NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
You want to delete any products supplied by the five suppliers located in Atlanta. Which script should you use?
DELETE FROM products
WHERE supplier_id IN
(SELECT supplier_id FROM suppliers WHERE UPPER(city) = 'ATLANTA');
One of the sales representatives, Janet Roper, has informed you that she was recently married, and she has
requested that you update her name in the employee database. Her new last name is Cooper. Janet is the only
person with the last name of Roper that is employed by the company. The EMPLOYEES table contains these
columns and all data is stored in lowercase:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT_ID VARCHAR2 (20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which UPDATE statement will accomplish your objective?
UPDATE employees
SET last_name = 'cooper'
WHERE last_name = 'roper';
One of your employees was recently married. Her employee ID is still 189, however, her last name is now
Rockefeller. Which SQL statement will allow you to reflect this change?
UPDATE my_employees SET last_name = 'Rockefeller' WHERE employee_ID = 189;
Assume all the column names are correct. The following SQL statement will execute which of the following?
INSERT INTO departments (department_id, department_name, manager_id, location_id)
VALUES (70, 'Public Relations', 100, 1700);
70 will be inserted into the department_id column
You need to display each employee's name in all uppercase letters. Which function should you use?
UPPER
Which SQL function is used to return the position where a specific character string begins within a larger character
string?
INSTR
You need to display the number of characters in each customer's last name. Which function should you use?
LENGTH
Which two functions can be used to manipulate number or date column values, but NOT character column values?
TRUNC
ROUND
You need to display the current year as a character value (for example: Two Thousand and One). Which element
would you use?
YEAR
You want to create a report that displays all orders and their amounts that were placed during the month of
January. You want the orders with the highest amounts to appear first. Which query should you issue?
SELECT orderid, total
FROM orders
WHERE order_date BETWEEN '01-jan-02' AND '31-jan-02'
ORDER BY total DESC;
Which three statements concerning explicit data type conversions are true?
Use the TO_DATE function to convert a character string to a date value.
Use the TO_NUMBER function to convert a character string of digits to a number.
Use the TO_CHAR function to convert a number or date value to character string.
Which SQL Statement should you use to display the prices in this format: "$00.30"?
SELECT TO_CHAR(price, '$99,900.99') FROM product;
Which of the following General Functions will return the first non-null expression in the expression list?
COALESCE
When joining 3 tables in a SELECT statement, how many join conditions are needed in the WHERE clause?
2
You have been asked to create a report that lists all corporate customers and all orders that they have placed. The
customers should be listed alphabetically beginning with the letter 'A', and their corresponding order totals should
be sorted from the highest amount to the lowest amount. Which of the following statements should you issue?
SELECT c.custid, c.companyname, o.orderdate, o. custid, o.amount FROM customers c, orders o WHERE c.custid
= o.custid ORDER BY companyname, amount DESC;
You need to create a report that lists all employees in department 10 (Sales) whose salary is not equal to $25,000
per year. Which query should you issue to accomplish this task?
SELECT last_name, first_name, salary
FROM employees
WHERE salary != 25000 AND department_id = 10;
The EMPLOYEE_ID column in the EMPLOYEES table corresponds to the EMPLOYEE_ID column of the ORDERS
table. The EMPLOYEE_ID column in the ORDERS table contains null values for rows that you need to
display. Which type of join should you use to display the data?
outer join
Using Oracle Proprietary join syntax, which two operators can be used in an outer join condition using the outer join
operator (+)?
AND and =
For which condition would you use an equijoin query with the USING keyword?
You need to perform a join of the CUSTOMER and ORDER tables but limit the number of columns in the join
condition.
SALES_ORDER
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the CUSTOMER table
ORDER_DT DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You need to create a report that displays customers without a sales order. Which statement could you use?
SELECT c.customer_name
FROM customers c
WHERE c.customer_id not in (SELECT s.customer_id FROM sales_order s);
What should be included in a SELECT statement to return NULL values from all tables?
full outer joins
Which query will retrieve all the rows in the EMPLOYEES table, even if there is no match in the DEPARTMENTS
table?
SELECT e.last_name, e.department_id, d.department_name
FROM employees e
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
Which type of join returns rows from one table that have NO direct match in the other table?
outer join
Which group function would you use to display the lowest value in the SALES_AMOUNT column?
MIN
Group functions return a value for ________________ and ________________ null values in their computations.
a row set, ignore
Which group function would you use to display the total of all salary values in the EMPLOYEE table?
SUM
You need to calculate the standard deviation for the cost of products produced in the Birmingham facility. Which
group function will you use?
STDDEV
You need to calculate the average salary of employees in each department. Which group function will you use?
AVG
You need to compute the total salary for all employees in department 10. Which group function will you use?
SUM
Which aggregate function can be used on a column of the DATE data type?
MAX
Which SELECT statement will calculate the number of rows in the PRODUCTS table?
SELECT COUNT (*) FROM products;
You want to write a report that returns the average salary of all employees in the company, sorted by departments.
The EMPLOYEES table contains the following columns:
EMPLOYEES:
EMPLOYEE_ID NUMBER(10) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
DEPARTMENT VARCHAR2(20)
HIRE_DATE DATE
SALARY NUMBER(10)
Which SELECT statement will return the information that you require?
SELECT AVG (salary)
FROM employees
GROUP BY department;
ORDERS
ORDER_ID NUMBER(10) NOT NULL PRIMARY KEY
EMPLOYEE_ID NUMBER(10) NOT NULL FOREIGN KEY
ORDER_DATE DATE
TOTAL NUMBER(10)
Which SELECT statement will return all orders generated by a sales representative named Franklin during the year
2001?
SELECT order_id, total
FROM ORDERS
WHERE employee_id = (SELECT employee_id FROM employees WHERE last_name = 'Franklin')
AND order_date BETWEEN '01-jan-01' AND '31-dec-01';
Using a subquery in which of the following clauses will return a syntax error?
You can use subqueries in all of the above clauses.
Which of the following is TRUE regarding the order of subquery execution?
The subquery executes once before the main query
Which operator can be used with subqueries that return only one row?
LIKE
DEPARTMENT
DEPARTMENT_ID NUMBER(9)
DEPARTMENT_NAME VARCHAR2(25)
CREATION_DATE DATE
ORDERS
ORDER_ID NUMBER(9)
EMPLOYEE_ID NUMBER(9)
DATE DATE
CUSTOMER_ID NUMBER(9)
You want to display all employees who had an order after the Sales department was established. Which of the
following constructs would you use?
a single-row subquery
Which of the following statements contains a comparison operator that is used to restrict rows based on a list of
values returned from an inner query?
All of the above.
What would happen if you attempted to use a single-row operator with a multiple-row subquery?
An error would be returned.
You need to display all the products that cost more than the maximum cost of every product produced in Japan.
Which multiple-row comparison operator could you use?
>ANY
DEPART_HIST:
EMPLOYEE_ID NUMBER(9)
OLD_DEPT_ID NUMBER(9)
NEW_DEPT_ID NUMBER(9)
CHANGE_DATE DATE
You want to generate a list of employees who are in department 10, but used to be in department 15.
Which query should you use?
SELECT employee_id, last_name, first_name, department_id
FROM employee
WHERE (employee_id, department_id) IN
(SELECT employee_id, new_dept_id
FROM depart_hist
WHERE old_dept_id = 15) AND new_dept_id = 10;
You have been instructed to add a new customer to the CUSTOMERS table. Because the new customer has not
had a credit check, you should not add an amount to the CREDIT column.
The CUSTOMERS table contains these columns:
CUST_ID NUMBER(10)
COMPANY VARCHAR2(30)
CREDIT NUMBER(10)
POC VARCHAR2(30)
LOCATION VARCHAR2(30)
Which two INSERT statements will accomplish your objective?
INSERT INTO customers (cust_id, company, poc, location)
VALUES (200, 'InterCargo', 'tflanders', 'samerica');
You need to update the area code of employees that live in Atlanta . Evaluate this partial UPDATE statement:
UPDATE employee
SET area_code = 770
Which of the following should you include in your UPDATE statement to achieve the desired results?
WHERE city = 'Atlanta';
What would happen if you issued a DELETE statement without a WHERE clause?
All the rows in the table would be deleted.
You need to delete a record in the EMPLOYEES table for Tim Jones, whose unique employee identification
number is 348. The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(5) PRIMARY KEY
LAST_NAME VARCHAR2(20)
FIRST_NAME VARCHAR2(20)
ADDRESS VARCHAR2(30)
PHONE NUMBER(10)
Which DELETE statement will delete the appropriate record without deleting any additional records?
DELETE FROM employees WHERE employee_id = 348;
Which two commands can be used to modify existing data in a database row?
MERGE
UPDATE
When the WHERE clause is missing in a DELETE statement, what is the result?
All rows are deleted from the table.
Which of the following represents the correct syntax for an INSERT statement?
INSERT INTO customers VALUES (3178, 'J.', 'Smith', '123 Main Street', 'Nashville', 'TN', '37777');
You want to enter a new record into the CUSTOMERS table. Which two commands can be used to create new
rows?
INSERT, MERGE
MANAGERS
MANAGER_ID NUMBER Primary Key
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
TEAM_ID NUMBER
TEAMS
TEAM_ID NUMBER Primary Key
TEAM_NAME VARCHAR2 (20)
OWNER_LAST_NAME VARCHAR2 (20)
OWNER_FIRST_NAME VARCHAR2 (20)
Which situation would require a subquery to return the desired result?
To display the names of the managers for all the teams owned by a given owner