Wednesday, 28 March 2012

Oracle OCA Exam Dump (Par-1)

Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 1 of 179
Contents
Objective
A. Writing Basic SQL Select Statements
B. Restricting and Sorting Data
C. Single-Row Functions & Group Functions.
D. Displaying Data from Multiple Tables
E. Subquerie
F. Creating and Managing Tables
G. Including Constraints
H. Manipulating Data
I. Creating Views
J. Creating Other Database Objects
K. Controlling User Access
► Relevant objective of each question is mentioned with question number.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 2 of 179
Question: 1. (A)
Which SELECT statement should you use if you want to display unique combinations of the
POSITION and MANAGER values from the EMPLOYEE table?
A. SELECT DISTINCT position, manager
FROM employee;
B. SELECT position, manager DISTINCT
FROM employee;
C. SELECT position, manager
FROM employee;
D. SELECT position, DISTINCT manager
FROM employee;
Answer: A
Explanation:
To display a unique values in the result you can use the DISTINCT key word this will eliminate
the duplicate values from the result of the query.
Question: 2. (A)
Which two are attributes of iSQL*Plus? (Choose two)
A. iSQL*Plus commands cannot be abbreviated.
B. iSQL*Plus commands are accesses from a browser.
C. iSQL*Plus commands are used to manipulate data in tables.
D. iSQL*Plus commands manipulate table definitions in the database.
E. iSQL*Plus is the Oracle proprietary interface for executing SQL statements.
Answer: B, E
Question: 3. (A)
You need to perform certain data manipulation operations through a view called EMP_DEPT_VU,
which you previously created.
You want to look at the definition of the view (the SELECT statement on which the view was
create.)
How do you obtain the definition of the view?
A. Use the DESCRIBE command in the EMP_DEPT VU view.
B. Use the DEFINE VIEW command on the EMP_DEPT VU view.
C. Use the DESCRIBE VIEW command on the EMP_DEPT VU view.
D. Query the USER_VIEWS data dictionary view to search for the EMP_DEPT_VU view.
E. Query the USER_SOURCE data dictionary view to search for the EMP_DEPT_VU view.
F. Query the USER_OBJECTS data dictionary view to search for the EMP_DEPT_VU view.
Answer: D
Explanation:
To look on the view definition you need to query the USER_VIEWS data dictionary view and
search for the EMP_DEPT_VU view.
Incorrect Answers
A: You cannot see the definition of the view using the DESCRIBE command.
B: There is no DEFINE VIEW command in Oracle.
C: There is no DESCRIBE VIEW command in Oracle.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 3 of 179
E: You cannot use the USER_SOURCE data dictionary view to see the definition of your view: it
is used to store system objects definitions only.
F: You can find record about view in the USER_OBJECTS, but it does not contain the definition
of the view itself.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 291-301
Chapter 7: Creating Other Database Objects in Oracle
Question: 4. (A)
Which is an /SQL*Plus command?
A. INSERT
B. UPDATE
C. SELECT
D. DESCRIBE
E. DELETE
F. RENAME
Answer: D
Explanation:
There is only one SQL*Plus command in this list: DESCRIBE. It cannot be used as SQL
command. This command returns a description of tablename, including all columns in that table,
the datatype for each column, and an indication of whether the column permits storage of NULL
values.
Incorrect Answers
A: INSERT is not a SQL*Plus command. It’s data-manipulation language (DML) command.
B: UPDATE is not a SQL*Plus command. It’s data-manipulation language (DML) command.
C: SELECT is not a SQL*Plus command.
E: DELETE is not a SQL*Plus command. It’s data-manipulation language (DML) command.
F: RENAME is not a SQL*Plus command.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 43
Chapter 1: Overview of Oracle Databases
Question: 5. (A)
You need to produce a report for mailing labels for all customers. The mailing label must have
only the customer name and address. The CUSTOMERS table has these columns:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 4 of 179
CUST_ID NUMBER(4) NOT NULL
CUST_NAME VARCHAR2(100)
CUST_ADDRESS VARCHAR2(150)
CUST_PHONE VARCHAR2(20)
Which SELECT statement accomplishes this task?
A. SELECT*
FROM customers;
B. SELECT name, address
FROM customers;
C. SELECT id, name, address, phone
FROM customers;
D. SELECT cust_name, cust_address
FROM customers;
E. SELECT cust_id, cust_name, cust_address, cust_phone
FROM customers;.
Answer: D
Explanation:
This answer provides correct list of columns for the output.
Incorrect Answers
A: This answer does not provide correct list of columns for the output. It is not required to show
all columns of the table. Symbol “*” is used in the SELECT command to substitute a list of all
columns of the table.
B: This answer does not provide correct list of columns for the output. There are not NAME and
ADDRESS columns in the CUSTOMERS table.
C: This answer does not provide correct list of columns for the output. There are not ID, NAME,
ADDRESS or PHONE columns in the CUSTOMERS table.
E: This answer does not provide correct list of columns for the output. It is not required to show all
columns of the table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 20-24
Chapter 1: Overview of Oracle Databases
Question: 6. (A)
Evaluate this SQL statement:
SELECT e.EMPLOYEE_ID,e.LAST_NAME,e.DEPARTMENT_ID, d.DEPARTMENT_NAME.
FROM EMP e, DEPARTMENT d
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID;
In the statement, which capabilities of a SELECT statement are performed?
A. Selection, projection, join
B. Difference, projection, join
C. Selection, intersection, join
D. Intersection, projection, join
E. Difference, projection, product
Answer: A
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 5 of 179
Explanation:
Selection, projection and join capabilities of a SELECT statement are performed in this view.
Incorrect Answers
B: Selection is performed in this query, not difference. There is no capability with name difference
for a SELECT statement exists.
C: There is no intersection in this SELECT statement used.
D: There is no intersection in this SELECT statement used.
E: There is no difference or product capabilities exist for a SELECT statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 20-21
Chapter 1: Overview of Oracle Databases
Question: 7. (A)
Which two statements are true regarding the ORDER BY clause? (Choose two)
A. The sort is in ascending by order by default.
B. The sort is in descending order by default.
C. The ORDER BY clause must precede the WHERE clause.
D. The ORDER BY clause is executed on the client side.
E. The ORDER BY clause comes last in the SELECT statement.
F. The ORDER BY clause is executed first in the query execution.
Answer: A & E
Explanation:
The ORDER BY clause does sort data in ascending order by default. And the ORDER BY clause
comes last in the SELECT statement: after FROM or WHERE or GROUP BY clause.
Incorrect Answers
B: The ORDER BY clause does sort data in ascending, not descending order, by default.
C: The ORDER BY clause must be after the WHERE clause in the SQL statement.
D: The ORDER BY clause is executed on the server side as the whole SQL statement is.
F: The ORDER BY clause is executed last in the query execution, after results are limited with
the WHERE and GROUP BY clause conditions.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 56-61
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 8. (A)
From SQL*Plus, you issue this SELECT statement:
SELECT*
From orders;
You use this statement to retrieve data from a data table for __________. (Choose all that apply)
A. Updating
B. Viewing
C. Deleting
D. Inserting
E. Truncating
Answer: B & D
Explanation:
You can use SELECT statement to display and to insert data into different table.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 6 of 179
Incorrect Answers
A: You cannot update data with SELECT statement. Update command is used for this purpose.
C: You cannot delete data with SELECT statement. Delete command is used for this purpose.
E: You cannot truncate data with SELECT statement. Truncate command is used for this
purpose.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 20-21
Chapter 1: Overview of Oracle Databases
Question: 9. (A)
Evaluate this SQL*Plus command:
START delaccount
Which task will this command accomplish?
A. It executes the DELACCOUNT PL/SQL routine.
B. It runs the DELACCOUNT.SQL script file.
C. It creates the DELACCOUNT file using the default file extension.
D. It invokes the editor to edit the contents of the DELACCOUNT file.
Answer: B
Explanation:
START is SQL*Plus command which is used to run the already stored script. It will not display the
actual command in the script.
Question: 10. (A)
Which SQL SELECT statement performs a projection, a selection, and join when executed?
A. SELECT p.id_number, m.manufacturer_id, m.city
FROM product p, manufacturer m
WHERE p.manufacturer_id = m.manufacturer_id
AND m.manufacturer_id = 'NF10032';
B. SELECT id_number, manufacturer_id
FROM product
ORDER BY manufacturer_id, id_number;
C. SELECT id_number, manufacturer_id
FROM product
WHERE manufacturer_id = 'NF10032';
D. SELECT manufacturer_id, city
FROM manufacturer
AND manufacturer_id = 'NF10032'
ORDER BY city;
Answer: A
Explanation:
PROJECTION will select the whole column values of the table while SELECTION will gives you
rows of the table and JOIN is joining the two tables on a same column. To get all these task done
in one statement you can use this command
SELECT p.id_number, m.manufacturer_id, m.city
FROM product p, manufacturer m
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 7 of 179
WHERE p.manufacturer_id = m.manufacturer_id
AND m.manufacturer_id = 'NF10032';
Question: 11. (A)
The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
STREET_ADDRESS VARCHAR2(150)
CITY_ADDRESS VARCHAR2(50)
STATE_ADDRESS VARCHAR2(50)
PROVINCE_ADDRESS VARCHAR2(50)
COUNTRY_ADDRESS VARCHAR2(50)
POSTAL_CODE VARCHAR2(12)
CUSTOMER_PHONE VARCHAR2(20)
Which statement finds the rows in the CUSTOMERS table that do not have a postal code?
A. SELECT customer_id, customer_name
FROM customers
WHERE postal_code CONTAINS NULL;
B. SELECT customer_id, customer_name
FROM customers
WHERE postal_code = '________';
C. SELECT customer_id, customer_name
FROM customers
WHERE postal_code IS NULL;
D. SELECT customer_id, customer_name
FROM customers
WHERE postal code IS NVL;
E. SELECT customer_id, customer_name
FROM customers
WHERE postal_code = NULL;
Answer: C
Explanation:
This statement returns the rows in the CUSTOMERS table that do not have a postal code. The
correct syntax to check NULL values is usage of “IS NULL” clause.
Incorrect Answers
A: “CONTAINS NULL” is incorrect clause in Oracle.
B: This statement will just check if postal code equals to string ‘________';
D: Usage of “IS NVL” is incorrect in Oracle. But there is a function NVL() you can use to process
NULL values.
E: You can not use equal comparison to check whether value is NULL or not. Use construction
“IS NULL” or “IS NOT NULL” to do that.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 31-32
Chapter 1: Overview of Oracle Databases
Question: 12. (A)
Evaluate these two SQL statements:
SELECT last_name, salary , hire_date
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 8 of 179
FROM EMPLOYEES
ORDER BY salary DESC;
SELECT last_name, salary, hire_date
FROM EMPLOYEES
ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending order by
default.
D. The two statements can be made to produce identical results by adding a column alias for the
salary column in the second SQL statement.
Answer: A
Explanation:
These two statements produce identical results, because it is possible even to use numbers to
indicate the column position where Oracle should order the output from a statement.
Incorrect Answers
B: Second statement is correct and it will not return a syntax error.
C: The results are sorted in ascending order by default.
D: There is no corrections need to be made for the statements. They will return identical results.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 56-61
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 13. (A)
Evaluate the set of SQL statements:
CREATE TABLE dept
(deptno NUMBER(2),
dname VARCNAR2(14),
loc VARCNAR2(13));
ROLLBACK;
DESCRIBE DEPT
What is true about the set?
A. The DESCRIBE DEPT statement displays the structure of the DEPT table.
B. The ROLLBACK statement frees the storage space occupies by the DEPT table.
C. The DESCRIBE DEPT statement returns an error ORA-04043: object DEPT does not exist.
D. The DESCRIBE DEPT statement displays the structure of the DEPT table only if the us a
COMMIT statement introduced before the ROLLBACK statement..
Answer: A
Explanation:
The structure of the DEPT table will be displayed because the CREATE TABLE statement is DDL
operation and it cannot be rolled back because implicit commit occurs on the database when a
user exits SQL*Plus or issues a data-definition language (DDL) command such as a create table
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 9 of 179
statement, user to create a database object, or an alter table statement, used to alter a database
object.
Incorrect Answers
B: The ROLLBACK statement has nothing to do with the storage space of the DEPT table.
C: The DESCRIBE DEPT statement does not produce the error. It displays the structure of the
DEPT table.
D: The COMMIT statement does not need to be introduced because implicit commit occurs on
the database after creation of the table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 281-283
Chapter 6: Manipulating Oracle Data
Question: 14. (A)
Examine the data of the EMPLOYEES table.
EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to
the EMPLOYEE_ID)
EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 HR_MGR 5000
106 Bryan 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EX_DIR 8000
120 Ravi 20 110 SA_DIR 6500
Evaluate this SQL statement:
SELECT e.employee_id "Emp_id", e.emp_name "Employee",
e.salary, m.employee_id "Mgr_id", m.emp_name "Manager"
FROM employees e, employees m
WHERE e.mgr_id = m.employee_id
AND e.salary > 4000;
What is its output?
A.
EMP_id EMPLOYEE SALARY Mgr_id Manager
------- ---------- --------- ------------- --------------
110 Bob 8000 Bob
120 Ravi 6500 110 Ravi
108 Jennifer 6500 110 Jennifer
103 Chris 4200 120 Chris
105 Diana 5000 108 Diana
B.
EMP_id EMPLOYEE SALARY Mgr_id Manager
------- ---------- --------- ------------- --------------
120 Ravi 6500 110 Bob
108 Jennifer 6500 110 Bob
103 Chris 4200 120 Ravi
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 10 of 179
105 Diana 500 108 Jennifer
C.
EMP_id EMPLOYEE SALARY Mgr_id Manager
------- ---------- --------- ------------- --------------
110 Bob 800
120 Ravi 6500 110 Bob
108 Jennifer 6500 110 Bob
103 Chris 4200 120 Ravi
105 Diana 5000 108 Jennifer
D
EMP_id EMPLOYEE SALARY Mgr_id Manager
------- ---------- --------- ------------- --------------
110 Bob 8000 110 Bob
120 Ravi 6500 120 Ravi
108 Jennifer 6500 108 Jennifer
103 Chris 4200 103 Chris
105 Diana 5000 105 Dina
E. The SQL statement produces an error.
Answer: B
Explanation:
This statement lists the ID, name, and salary of the employee, and the ID and name of the
employee's manager, for all the employees who have a manager and earn more than 4000
Incorrect Answers
A: This output will be provided by different query.
C: This output will be provided by different query.
D: This output will be provided by different query.
E: This SQL query will not produce error, it will show results as in answer B.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 118-122
Chapter 3: Advanced Data Selection in Oracle
Question: 15. (A)
Which /SQL*Plus feature can be used to replace values in the WHERE clause?
A. Substitution variables
B. Replacement variables
C. Prompt variables
D. Instead-of variables
E. This feature cannot be implemented through /SQL*Plus.
Answer: A
Explanation:
Lexical substitution variables can be used to replace values in the WHERE clause.
Incorrect Answers
B: There is no replacement variables SQL*Plus feature in Oracle.
C: There is no prompt variables SQL*Plus feature in Oracle.
D: There is no instead-of variables SQL*Plus feature in Oracle.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 11 of 179
E: This feature is implemented in the SQL*Plus with lexical substitution variables.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 165-173
Chapter 4: Subqueries
Question: 16. (A)
You are formulating queries in a SQL*Plus. Which of the following statement correctly describes
how to specify a column alias?
A. Place the alias at the beginning of the statement to describe the table.
B. Place the alias after each column separated by a space to describe the column.
C. Place the alias after each column separated by a comma to describe the column.
D. Place the alias at the end of the statement to describe the table.
Answer: B
Explanation:
Aliases do not describe the tables they describe columns so the alias should be place at the end
of each column and separated by a space to describe the column.
Question: 17. (A)
You want to use a function in you column clause of a SQL statement. The NVL function
accomplishes which of the following tasks?
A. Assists in the distribution of output across multiple columns.
B. Enables you to specify alternate output for non-NULL column values.
C. Enables you to specify alternated out for NULL column values.
D. Nullifies the value of the column out put.
Answer: C
Explanation:
NVL function is simple if_then operation that test column values out to see whether it is NULL and
if it find it is null then NVL substitutes the specified default value for the NULL value.
Question: 18. (A)
You want to use SQL*Plus to connect to the oracle database. Which of the following choices
does not indicate a component you must specify when logging into the oracle?
A. The SQL*Plus Keyword.
B. The username
C. The password.
D. The database name.
Answer: D
Explanation:
When connecting to the database you don’t need to specify the name of the database and when
you are not specifying the name of the database then you will be connected to the local database.
Question: 19. (A)
The EMPLOYEE_HISTORY table contains these columns:
EMPLOYEE_ID NUMBER
LAST_NAME VARCHAR2(25)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 12 of 179
FIRST_NAME VARCHAR2(25)
DEPARTMENT_ID NUMBER
POSITION VARCHAR2(30)
SALARY NUMBER(6,2)
HIRE_DATE DATE
DEPART_DATE DATE
The EMPLOYEE_HISTORY table contains only former employees.
You need to create a report to display all former employees that were hired on or
after January 1, 1996. The data should display in this format:
Former Employee Term of Employment
---------------------------- ----------------------------------
14837 - SMITH 10-MAY-92 / 01-JUN-01
Which SELECT statement could you use?
A. SELECT employee_id||' - '||last_name AS Former Employee,
hire_date||' / '||depart_date AS Term of Employment
FROM employee_history
WHERE hire_date > '31-DEC-95';
B. SELECT employee_id||' - '||last_name "AS Former Employee",
hire_date||' / '||depart_date "AS Term of Employment"
FROM employee_history
WHERE hire_date > '31-DEC-95';
C. SELECT employee_id||' - '||last_name 'Former Employee',
hire_date||' / '||depart_date 'Term of Employment'
FROM employee_history
WHERE hire_date > '31-DEC-95'
AND depart_date > NULL;
D. SELECT employee_id||' - '||last_name "Former Employee",
hire_date||' / '||depart_date "Term of Employment"
FROM employee_history
WHERE hire_date > '31-DEC-95'
AND depart_date <> NULL;
E. SELECT employee_id||' - '||last_name "Former Employee",
hire_date||' / '||depart_date "Term of Employment"
FROM employee_history
WHERE hire_date > '31-DEC-95'
AND depart_date IS NOT NULL;
Ans. E
Reference:
Introduction to Oracle9i: SQL - Writing Basic SQL SELECT Statements
Question: 20. (A)
The EMPloyee table contains these columns:
Empno Number(4)
Ename Varchar2(10)
job varchar2(10)
sal Varchar2(10)
You need to display the employees information by using this query.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 13 of 179
How many columns are presented after executing this query:
SELECT Empno||','||Ename||','||Job "Employee Information" FROM employee;
A) 1
B) 2
C) 3
D) 0
E) 4
Answer: A.
Explanation
When we used Concatenation operator between different no of columns so then one Column as a
resultant column is to be apperead.
Incorrect answers
B.Not 2
C.Not 3
D.Not 0
E.Not 4
Reference:
Introduction to Oracle9i: SQL - Writing Basic SQL SELECT Statements
Question: 21.(B)
Examine the data of the EMPLOYEES table.
EMPLOYEES (EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers and refers to
the EMPLOYEE_ID)
EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 HR_MGR 5000
106 Bryan 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EX_DIR 8000
120 Ravi 20 110 SA_DIR 6500
Which statement lists the ID, name, and salary of the employee, and the ID and name of the
employee's manager, for all the employees who have a manager and earn more than 4000?
A. SELECT employee_id "Emp_id", emp_name "Employee",
salary,
employee_id "Mgr_id", emp_name "Manager"
FROM employees
WHERE salary > 4000;
B. SELECT e.employee_id "Emp_id", e.emp_name "Employee",
e.salary,
m.employee_id "Mgr_id", m.emp_name "Manager"
FROM employees e, employees m
WHERE e.mgr_id = m.mgr_id
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 14 of 179
AND e.salary > 4000;
C. SELECT e.employee_id "Emp_id", e.emp_name "Employee",
e.salary,
m.employee_id "Mgr_id", m.emp_name "Manager"
FROM employees e, employees m
WHERE e.mgr_id = m.employee_id
AND e.salary > 4000;
D. SELECT e.employee_id "Emp_id", e.emp_name "Employee",
e.salary,
m.mgr_id "Mgr_id", m.emp_name "manager"
FROM employees e, employees m
WHERE e.mgr_id = m.employee_id
AND e.salary > 4000;
E. SELECT e.employee_id "Emp_id", e.emp_name "Employee",
e.salary,
m.mgr_id "Mgr_id", m.emp_name "Manager"
FROM employees e, employees m
WHERE e.employee_id = m.employee_id
AND e.salary > 4000;.
Answer: C
Explanation:
This statement lists the ID, name, and salary of the employee, and the ID and name of the
employee's manager, for all the employees who have a manager and earn more than 4000
Incorrect Answers
A: This statement does not check does employee have a manager or not, so it will not provide
correct result.
B: Usage of “e.mgr_id = m.mgr_id” condition is wrong to achieve required result.
D: This statement uses “m.mgr_id” to show manager’s manager, not employ’s manager.
E: Usage of “WHERE e.employee_id = m.employee_id” condition is wrong to achieve required
result.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 118-122
Chapter 3: Advanced Data Selection in Oracle
Question: 22. (B)
You need to display the last names of those employees who have the letter “A” as the second
character in their names.
Which SQL statement displays the required results?
A. SELECT last_name
FROM EMP
WHERE last_name LIKE ‘_A%’;
B. SELECT last_name
FROM EMP
WHERE last name =’*A%’
C. SELECT last_name
FROM EMP
WHERE last name =’_A%’;
D. SELECT last_name
FROM EMP
WHERE last name LIKE ‘*A%’
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 15 of 179
Answer: A
Explanation:
Statement in this answer will show correct results because usage of operator LIKE and format
mask ‘_A%’ extract the last names of those employees who have the letter “A” as the second
character in their names. Symbol ‘_’ in format mask substitute exactly one symbol and cannot be
NULL.
Incorrect Answers
B: This statement will return only names starting from symbol ‘*’. It cannot be used as substitution
symbol.
C: Usage of equity operator here is not appropriate in this case: query will look exact for first
symbol ‘_’, it will not be considered as substitution symbol.
D: This statement will return only names starting from symbol ‘*’. It cannot be used as substitution
symbol.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 61-67
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 23. (B)
In which scenario would TOP N analysis be the best solution?
A. You want to identify the most senior employee in the company.
B. You want to find the manager supervising the largest number of employees.
C. You want to identify the person who makes the highest salary for all employees.
D. You want to rank the top three sales representatives who have sold the maximum number of
products.
Answer: D
Explanation:
If you want to rank the top three sales representatives who have sold the maximum number of
products TOP-N query will be the best solution. TON-N queries use inline views and are handy
for displaying a short list of table data, based on “greatest” or “least” criteria.
Incorrect Answers
A: To complete this request you don’t need to use TOP-N query.
B: It is not necessary to use TOP-N query in this case.
C: To complete this request you don’t need to use TOP-N query.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 162-165
Chapter 4: Subqueries
Question: 24. (B)
Evaluate this SQL statement:
SELECT c.customer_id, o.order_id, o.order_date, p.product_name
FROM customer c, curr_order o, product p
WHERE customer.customer_id = curr_order.customer_id
AND o.product_id = p.product_id
ORDER BY o.order_amount;
This statement fails when executed. Which change will correct the problem?
A. Include the ORDER_AMOUNT column in the SELECT list.
B. Use the table name in the ORDER BY clause.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 16 of 179
C. Remove the table aliases from the WHERE clause.
D. Use the table aliases instead of the table names in the WHERE clause.
E. Remove the table alias from the ORDER BY clause and use only the column name.
Answer: D
Explanation:
When an alias is define for a table name in join then you cannot use the table name instead of
alias in the FROM clause while using alias in the SELECT list. An alias should be used in the
WHERE clause also.
Question: 25. (B)
You want to display the titles of books that meet these criteria:
1. Purchased before January 21, 2001
2. Price is less then $500 or greater than $900
You want to sort the results by their data of purchase, starting with the most recently bought
book.
Which statement should you use?
A. SELECT book_title
FROM books
WHERE price between 500 and 900
AND purchase_date < ’21-JAN-2001’
ORDER BY purchase_date;
B. SELECT book_title
FROM books
WHERE price IN (500,900)
AND purchase_date < ’21-JAN-2001’
ORDER BY purchase date ASC;
C. SELECT book_title
FROM books
WHERE price < 500 or > 900
AND purchase_date < ’21-JAN-2001’
ORDER BY purchase date DESC;
D. SELECT book_title
FROM books
WHERE (price < 500 OR price > 900)
AND purchase_date < ’21-JAN-2001’
ORDER BY purchase date DESC;
Answer: D
Explanation:
This statement provides required results.
Incorrect Answers
A: This query will show books with price in range $500 and $900, not less then $500 or greater
than $900.
B: This query will show books with prices exactly $500 or $900, not less then $500 or greater
than $900.
C: This order will not show correct rows because of incorrect syntax in the WHERE clause.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 56-66
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 17 of 179
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 26. (B)
For which task would you use the WHERE clause in a SELECT statement?
A. to designate the ORDER table location
B. to compare PRODUCT_ID values to 7382
C. to display only unique PRODUCT_ID values
D. to restrict the rows returned by a GROUP BY clause
Answer: B
Explanation:
You can use the WHERE clause in the SELECT statement to implement the condition on the
statement by comparing values.
Question: 27. (B)
The STUDENT_GRADES table has these columns:
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
The registrar has requested a report listing the students' grade point averages (GPA), sorted from
highest grade point average to lowest within each semester, starting from the earliest date. Which
statement accomplishes this?
A. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end DESC, gpa DESC;
B. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end ASC, gpa ASC;
C. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY semester_end, gpa DESC;
D. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY gpa DESC, semester_end DESC;
E. SELECT student_id, semester_end, gpa
FROM student_grades
ORDER BY gpa DESC, semester_end ASC;.
Answer: C
Explanation:
This answer shows correct syntax and semantics to receive desired result.
Incorrect Answers
A: Semesters will be sorted started from the oldest date, not the earliest.
B: GPA data will be sorted in ascending order, what is opposite to our task.
D: Semesters will be sorted started from the oldest date, not the earliest. Only difference with
answer A is order of columns in the ORDER BY clause.
E: This query has wrong order of columns to sort: results need to be sorted first by semester,
than by grade point average.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 18 of 179
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 56-61
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 28. (B)
The ORDERS table has these columns:
ORDER_ID NUMBER(4) NOT NULL
CUSTOMER_ID NUMBER(12) NOT NULL
ORDER_TOTAL NUMBER(10,2)
The ORDERS table tracks the Order nnmher, the order total, and the customer to whom the
Order belongs. Which two statements retrieve orders with an inclusive total that ranges between
100.00 and 2000.00 dollars? (Choose two.)
A. SELECT customer_id, order_id, order_total
FROM orders
RANGE ON order_total (100 AND 2000) INCLUSIVE;
B. SELECT customer_id, order_id, order_total
FROM orders
HAVING order_total BETWEEN 100 and 2000;
C. SELECT customer_id, order_id, order_total
FROM orders
WHERE order_total BETWEEN 100 and 2000;
D. SELECT customer_id, order_id, order_total
FROM orders
WHERE order_total >= 100 and <= 2000;
E. SELECT customer_id, order_id, order_total
FROM orders
WHERE order_total >= 100 and order_total <= 2000;
Answer: C & E
Explanation:
Answers C and E provide correct results to show. You can use BETWEEN or comparison
operations to retrieve data.
Incorrect Answers
A: There is no RANGE ON or INCLUSIVE keyword in Oracle.
B: HAVING clause can be use only in conjunction with the GROUP BY clause.
D: Syntax “order_total >= 100 and <= 2000” is incorrect.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 61-67
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 29. (B)
Examine the structure of the PRODUCT table.
PRODUCT Table
PRODUCT _ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2
(25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the
SUPPLIER table
CATERORY_ID NUMBER
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 19 of 179
QTY_PER_UNIT NUMBER
LIST_RRICE NUMBER (5,2)
COST NUMBER (5,2)
You want to display all product identification numbers of products for which there are 500 or more
available for immediate sale. You want the product numbers displayed alphabetically by supplier,
then by product number from lowest to highest. Which statement should you use to achieve the
required results?
A. SELECT product_id
FROM product
WHERE qty_per_unit >= 500
ORDER BY supplier_id, product_id;
B. SELECT product_id
FROM product
WHERE qty_per_unit >= 500
SORT BY supplier_id, product_id;
C. SELECT product_id
FROM product
WHERE qty_per_unit >= 500
ORDER BY supplier_id, product_id DESC;
D. SELECT product_id
FROM product
WHERE qty_per_unit > 500
SORT BY supplier_id, product_id;
Answer: A
Explanation:
SELECT product_id
FROM product
WHERE qty_per_unit >= 500
ORDER BY supplier_id, product_id;
This statement will give the product_id from product table where qty_per_unit will be equal to and
greater than 500 and it will sort it in ascending order by default.
Question: 30. (B)
Examine the data in TEACHER table.
ID LAST_NAME FIRST_NAME SUBJECT_ID
88 Tsu Ming HST AMER
70 Smith Ellen HST INDIA
56 Jones Karen HST_REVOL
58 Hann Jeff HST CURR
63 Hopewell Mary Elizabetn HST_RELIG
Which query should you use to return the following values from the TEACHER table?
Name Subject
------------------------------------- -------------------
Jones, Karen HST_REVOL
Hopewell, Mary Elizabeth HST_RELIG
A. SELECT last_name||', '||first_name "Name", subject_id "Subject"
FROM teacher
WHERE subject_id LIKE 'HST\_%' ESCAPE '\';
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 20 of 179
B. SELECT last_name||', '||first_name "Name", subject_id "Subject"
FROM teacher
WHERE subject_id = 'HST\_R%';
C. SELECT last_name||', '||first_name "Name", subject_id "Subject"
FROM teacher
WHERE subject_id LIKE '%HST\_R%' ESC '\';
D. SELECT last_name||', '||first_name "Name", subject_id "Subject"
FROM teacher
WHERE subject_id LIKE 'HST_%';
Answer: A
Explanation:
When you need to have an exact match for the actual ‘%’ and ‘_’ characters use the ESCAPE
option. This option specifies what the ESCAPE character is.
Question: 31. (B)
You query the database with this SQL statement:
SELECT bonus
FROM salary
WHERE bonus BETWEEN 1 AND 250
OR (bonus IN(190, 500, 600)
AND bonus BETWEEN 250 AND 500);
Which value could the statement return?
A. 100
B. 260
C. 400
D. 600
Answer: A
Explanation:
For the above statement the value of bonus return will be 100. After resolving the above written
operators the result return would be 100.
Question: 32. (B)
Examine the structure of the STUDENTS table:
STUDENT_ID NUMBER NOT NULL, Primary
Key
STUDENT_NAME VARCHAR2(30)
COURSE_ID VARCHAR2(10) NOT NULL
MARKS NUMBER
START_DATE DATE
FINISH_DATE DATE
You need to create a report of the 10 students who achieved the highest ranking in the course
INT SQL and who completed the course in the year 1999.
Which SQL statement accomplishes this task?
A. SELECT student_ id, marks, ROWNUM "Rank"
FROM students
WHERE ROWNUM <= 10
AND finish_date BETWEEN '01-JAN-99' AND '31-DEC-99'
AND course_id = 'INT_SQL'
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 21 of 179
ORDER BY marks DESC;
B. SELECT student_id, marks, ROWID "Rank"
FROM students
WHERE ROWID <= 10
AND finish_date BETWEEN '01-JAN-99' AND '31-DEC-99'
AND course_id = 'INT_SQL'
ORDER BY marks;
C. SELECT student_id, marks, ROWNUM "Rank"
FROM (SELECT student_id, marks
FROM students
WHERE ROWNUM <= 10
AND finish_date BETWEEN '01-JAN-99' AND
'31-DEC-99'
AND course_id = 'INT_SQL'
ORDER BY marks DESC);
D. SELECT student_id, marks, ROWNUM "Rank”
FROM (SELECT student_id, marks
FROM students
ORDER BY marks DESC)
WHERE ROWNUM <= 10
AND finish_date BETWEEN '01-JAN-99' AND '31-DEC-99'
AND course_id = 'INT_SQL';
Answer: D
Explanation:
This statement using inline sub-query will provide correct results to show 10 students who
achieved the highest ranking in the course INT SQL and who completed the course in the year
1999.
Incorrect Answers
A: This view will just show first 10 students from the STUDENTS table with limitation on the
course INT SQL and who completed the course in the year 1999.
B: It’s wrong to use here ROWID to achieve desired results.
C: This statement will provide wrong result due to wrong conditions in the inline sub-query.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 162-165
Chapter 4: Subqueries
Question: 33. (B)
Examine the structure of the LINE_ITEM table.
LINE_ITEM_ID NUMBER(9) NOT NULL, Primary Key
ORDER_ID NUMBER(9) NOT NULL, Primary Key, Foreign Key to
ORDER_ID column of the CURR_ORDER table
PRODUCT_ID NUMBER(9) NOT_NULL, Foreign Key to PRODUCT_ID column
of the PRODUCT table
QUANTITY NUMBER(9)
You must display the order number, line item number, product identification number, and quantity
of each item where the quantity ranges from 10 through 100. The order numbers must be in the
range of 1500 through 1575. The results must be sorted by order number from lowest to highest
and then further sorted by quantity from highest to lowest.
Which statement should you use to display the desired result?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 22 of 179
A. SELECT order_id, line_item_id, product_id, quantity
FROM line_item
WHERE quantity BETWEEN 9 AND 101
AND order_id BETWEEN 1500 AND 1575
ORDER BY order_id DESC, quantity DESC;
B. SELECT order_id, line_item_id, product_id, quantity
FROM line_item
WHERE (quantity > 10 AND quantity < 100)
AND order_id BETWEEN 1500 AND 1575
ORDER BY order_id ASC, quantity;
C. SELECT order_id, line_item_id, product_id, quantity
FROM line_item
WHERE (quantity > 9 OR quantity < 101)
AND order_id BETWEEN 1500 AND 1575
ORDER BY order_id, quantity;
D. SELECT order_id, line_item_id, product_id, quantity
FROM line_item
WHERE quantity BETWEEN 10 AND 100
AND order_id BETWEEN 1500 AND 1575
ORDER BY order_id, quantity DESC;
Answer: D
Explanation:
Following query will give all the desire result by using to condition with ORDER BY clause with
order_id by default will be sorted in ascending order and quantity will be sorted in descending
order
SELECT order_id, line_item_id, product_id, quantity
FROM line_item
WHERE quantity BETWEEN 10 AND 100
AND order_id BETWEEN 1500 AND 1575
ORDER BY order_id, quantity DESC;
Question: 34. (B)
The ITEM table contains these columns:
ITEM_ID NUMBER(9)
COST NUMBER(7,2)
RETAIL NUMBER(7,2)
You need to create a report that displays the cost, the retail price, and the profit for item number
783920. To calculate the profit, subtract the cost of the item from its retail price, and then deduct
an administrative fee of 25 percent of this derived value.
Which SELECT statement produces the desired results?
A. SELECT cost, retail, (retail - cost) - ((retail - cost) * .25) "Profit"
FROM item
WHERE item_id = 783920;
B. SELECT cost, retail, (retail - cost) - retail - (cost * .25) "Profit"
FROM item
WHERE item_id = 783920;
C. SELECT cost, retail, (retail - cost - retail - cost) * .25 "Profit"
FROM item
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 23 of 179
WHERE item_id = 783920;
D. SELECT cost, retail, retail - cost - retail - cost * .25 "Profit"
FROM item
WHERE item_id = 783920;
Answer: A
Explanation:
To get a complete desired report you can use the following query with expressions
SELECT cost, retail, (retail - cost) - ((retail - cost) * .25) "Profit"
FROM item
WHERE item_id = 783920;
Question: 35. (B)
The ITEM table contains these columns:
ITEM_ID NUMBER(9)
COST NUMBER(7,2)
RETAIL NUMBER(7,2)
The RETAIL and COST columns contain values greater than zero.
Evaluate these two SQL statements:
1. SELECT item_id, (retail * 1.25) + 5.00 - (cost * 1.10) - (cost * .10) AS Calculated Profit
FROM item;
2. SELECT item_id, retail * 1.25 + 5.00 - cost * 1.10 - cost * .10 "Calculated Profit"
FROM item;
What will be the result?
A. Statement 1 will display the 'Calculated Profit' column heading.
B. Statement 1 and statement 2 will return the same value.
C. Statement 1 will return a higher value than statement 2.
D. One of the statements will NOT execute.
Answer: D
Explanation:
For the above written statements the first statement will not execute because the column alias
contain spaces so it should be place in the a double quotation marks for the statement to execute
successful.
Question: 36. (B)
The EMP table contains these columns:
LAST NAME VARCHAR2(25)
SALARY NUMBER(6,2)
DEPARTMENT_ID NUMBER(6)
You need to display the employees who have not been assigned to any department.
You write the SELECT statement:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 24 of 179
SELECT LAST_NAME, SALARY, DEPARTMENT_ID
FROM EMP
WHERE DEPARTMENT_ID = NULL;
What is true about this SQL statement?
A. The SQL statement displays the desired results.
B. The column in the WHERE clause should be changed to display the desired results.
C. The operator in the WHERE clause should be changed to display the desired results.
D. The WHERE clause should be changed to use an outer join to display the desired results.
Answer: C
Explanation:
The operator in the WHERE clause should be changed to display the desired results. There are
times when you want to substitute a value in place of NULL. Oracle provides this functionality with
a special function, called NVL(). You cannot use operation equal with NULL, but you can achieve
desired results using NVL() function after the WHERE clause.
Incorrect Answers
A: The SQL statement will generate an error because you cannot use operation equal with NULL.
B: The column in the WHERE clause should not be changed to display the desired results.
D: Since there is only one table used in this query you don’t need to use outer join to display the
desired results.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 31-32
Chapter 1: Overview of Oracle Databases
Question: 37. (B)
Which two statements are true about WHERE and HAVING clauses? (Choose two)
A. A WHERE clause can be used to restrict both rows and groups.
B. A WHERE clause can be used to restrict rows only.
C. A HAVING clause can be used to restrict both rows and groups.
D. A HAVING clause can be used to restrict groups only.
E. A WHERE clause CANNOT be used in a query of the query uses a HAVING clause.
F. A HAVING clause CANNOT be used in subqueries.
Answer: B, D
Question: 38. (B)
You are sorting data in a table in you SELECT statement in descending order. The column you
are sorting on contains NULL records, where will the NULL record appears?
A. At the beginning of the list.
B. At the end of the list.
C. In the middle of the list.
D. At the same location they are listed in the unordered table.
Answer: A
Explanation:
When sorting a column with null values in ascending order then the oracle places the Null values
at the end of the list if the sorting is in descending order the oracle places the null values at the
start of the list.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 25 of 179
Question: 39. (B)
The ACCOUNT table contains these columns:
ACCOUNT_ID NUMBER(12)
PREVIOUS_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
NEW_PURCHASES NUMBER(7,2)
CREDIT_LIMIT NUMBER(7)
You need to display the account number, finance charge, and current balance for accounts 1500
through 2000 with a current balance greater than the account's credit limit.
The finance charge is .9 percent (.009) of the previous balance. Adding the previous balance
value,
new purchases value, and finance charge value, and then subtracting the payments value yields
the current balance value.
Evaluate this statement:
SELECT account_id, NVL(previous_balance, 0) * .009 finance_charge,
NVL(new_purchases, 0) + (NVL(previous_balance, 0) * 1.009) - NVL(payments, 0)
current balance
FROM account
WHERE (new_purchases + (previous_balance * 1.009)) - payments > credit_limit
AND account_id BETWEEN 1500 AND 2000;
Which statement about this SELECT statement is true?
A. The statement calculates the finance charge incorrectly.
B. The statement calculates the current balance incorrectly.
C. The statement returns only accounts that have NO previous balance.
D. The statement returns only accounts that have new purchases, previous balance, and
payments values.
Ans. D
Incorrect answers
A. The statement calculates the finance charge incorrectly.
B. The statement calculates the current balance incorrectly.
C. The statement returns only accounts that have NO previous balance.
References:
1. Introduction to Oracle9i: SQL - Restricting and Sorting Data
Question: 40.(C)
Examine the description of the EMPLOYEES table:
EMP_ID NUMBER(4) NOT NULL
LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(30)
DEPT_ID NUMBER(2)
JOB_CAT VARCHARD2(30)
SALARY NUMBER(8,2)
Which statement shows the maximum salary paid in each job category of each department?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 26 of 179
A. SELECT dept_id, job_cat, MAX(salary)
FROM employees
WHERE salary > MAX(salary);
B. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id, job_cat;
C. SELECT dept_id, job_cat, MAX(salary)
FROM employees;
D. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id;
E. SELECT dept_id, job_cat, MAX(salary)
FROM employees
GROUP BY dept_id, job_cat, salary;
Answer: B
Explanation:
This answer provides correct syntax and semantics to show the maximum salary paid in each job
category of each department.
Incorrect Answers
A: This query will not return any row because condition SALARY > MAX(SALARY) is FALSE.
C: This query will return error because you cannot show maximum salary with DEPT_ID and
JOB_CAT without grouping by these columns.
D: The GROUP BY clause is missing JOB_ID column.
E: You don’t need to group results of query by SALARY in the GROUP BY column.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-365
Chapter 8: User Access Control in Oracle
Question: 41. (C)
Management has asked you to calculate the value 12*salary* comossion_pct for all the
employees in the EMP table. The EMP table contains these columns:
LAST NAME VARCNAR2(35) NOT NULL
SALARY NUMBER(9,2) NOT NULL
COMMISION_PCT NUMBER(4,2)
Which statement ensures that a value is displayed in the calculated columns for all employees?
A. SELECT last_name, 12*salary*commison_pct
FROM emp;
B. SELECT last_name, 12*salary* (commission_pct,0)
FROM emp;
C. SELECT last_name, 12*salary*(nvl(commission_pct,0))
FROM emp;
D. SELECT last_name, 12*salary*(decode(commission_pct,0))
FROM emp;
Answer: C
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 27 of 179
This SELECT statement provides correct usage of NVL function to calculate columns for all
employees. Oracle give you possibility to substitute a value in place of NULL. The basic syntax
for NVL() is NVL(column_name, value_if_null). Notice that the column specified in NVL() contains
an actual value. That value is what Oracle returns; when the column is NULL, the special string is
returned. The value specified to be returned if the column value is NULL must be the same
datatype as the column specified.
Incorrect Answers
A: This SELECT statement will return NULL value for rows with NULL COMMISION_PCT
column.
B: It is incorrect syntax in this query: NVL function needs to be used for correct result.
D: The DECODE function is used as substitution of IF-THEN-ELSE PL/SQL construction in SQL
queries. The SELECT statement provides incorrect syntax of it cannot have only two
parameters.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 31-32
Chapter 1: Overview of Oracle Databases
Question: 42. (C)
Examine the description of the STUDENTS table:
STD_ID NUMBER(4)
COURSE_ID VARCHARD2(10)
START_DATE DATE
END_DATE DATE.
Which two aggregate functions are valid on the START_DATE column? (Choose two)
A. SUM(start_date)
B. AVG(start_date)
C. COUNT(start_date)
D. AVG(start_date, end_date)
E. MIN(start_date)
F. MAXIMUM(start_date)
Answer: C & E
Explanation:
It is possible to apply COUNT() and MIN() functions on the column with DATE data type.
Incorrect Answers
A: Function SUM() cannot be used with DATE data type column.
B: Function AVG() cannot be used with DATE data type column.
D: Function AVG() cannot be used with DATE data type column. And function AVG() just has one
parameter X, not two. It averages all X column values returned by the SELECT statement.
F: There is no MAXIMUM() function in Oracle, only MAX() function exists.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 81-85
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 43. (C)
The EMPLOYEE tables has these columns:
LAST_NAME VARCNAR2(35)
SALARY NUMBER(8,2)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 28 of 179
COMMISSION_PCT NUMBER(5,2)
You want to display the name and annual salary multiplied by the commission_pct for all
employees. For records that have a NULL commission_pct, a zero must be displayed against the
calculated column. Which SQL statement displays the desired results?
A. SELECT last_name, (salary * 12) * commission_pct
FROM EMPLOYEES;
B. SELECT last_name, (salary * 12) * IFNULL(commission_pct,
0)
FROM EMPLOYEES;
C. SELECT last_name, (salary * 12) * NVL2(commission_pct, 0)
FROM EMPLOYEES;
D. SELECT last_name, (salary * 12) * NVL(commission_pct, 0)
FROM EMPLOYEES;
Answer: D
Explanation:
This SELECT statement provides correct usage of NVL function to calculate columns for all
employees. Oracle give you possibility to substitute a value in place of NULL. The basic syntax
for NVL() is NVL(column_name, value_if_null). Notice that the column specified in NVL() contains
an actual value. That value is what Oracle returns; when the column is NULL, the special string
isreturned. The value specified to be returned if the column value is NULL must be the same
datatype as the column specified.
Incorrect Answers
A: This SELECT statement will return NULL value for rows with NULL COMMISION_PCT
column.
B: There is no IFNULL() function in Oracle.
C: The NVL2() function requires 3 parameters, not 2. Function NVL2(expr1, expr2, expr3) returns
expr2 if expr1 is not NULL. If expr1 is NULL, it returns expr3.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 31-32
Chapter 1: Overview of Oracle Databases
Question: 44. (C)
You would like to display the system date in the format "Monday, 01 June, 2001".
Which SELECT statement should you use?
A. SELECT TO_DATE(SYSDATE, 'FMDAY, DD Month, YYYY')
FROM dual;
B. SELECT TO_CHAR(SYSDATE, 'FMDD, DY Month, 'YYY')
FROM dual;
C. SELECT TO_CHAR(SYSDATE, 'FMDay, DD Month, YYYY')
FROM dual;
D. SELECT TO_CHAR(SYSDATE, 'FMDY, DDD Month, YYYY')
FROM dual;
E. SELECT TO_DATE(SYSDATE, 'FMDY, DDD Month, YYYY')
FROM dual;
Answer: C
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 29 of 179
This answer is correct: “Day” shows the day spelled out, “DD” shows the two-digit date, “Month”
provides the month spelled out, “YYYY” shows the four-digit year. “FMDay” is special format
mask to suppresses the extra spaces between the name of the day and the number of the date.
Incorrect Answers
A: This statement will return an error because of inappropriate usage of the TO_DATE() function.
B: Incorrect format mask “DY” is used to show the number of the day.
D: Incorrect format mask “DY” is used to show the name of the day and format mask “DDD” is
used to show the number of the day.
E: Incorrect format mask “DY” is used to show the name of the day and format mask “DDD” is
used to show the number of the day. Also this statement will return an error because of
inappropriate usage of the TO_DATE() function.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 87-88
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 45. (C)
Evaluate the SQL statement:
SELECT ROUND(TRUNC(MOD(1600,10),-1),2)
FROM dual;
What will be displayed?
A. 0
B. 1
C. 0.00
D. An error statement
Answer: A
Explanation:
Result will be 0. MOD(x,y) function calculates the modulus of x, defined in long division as the
integer remainder when x is divided by y until no further whole number can be produced.
TRUNC() function truncates x to the decimal precision of y. ROUND(x,y) rounds x to the decimal
precision of y.
Incorrect Answers
B: Result will be 0, not 1.
C: Result will be 0, not 0.00 because MOD(1600,10) return 0 and all other functions (TRUNC and
ROUND) return 0 also.
D: There is no error in this statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 69-71
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 46. (C)
Examine the description of the MARKS table:
STD_ID NUMBER(4)
STUDENT_NAME VARCHAR2(30)
SUBJ1 NUMBER(3)
SUBJ2 NUMBER(3)
SUBJ1 and SUBJ2 indicate the marks obtained by a student in two subjects.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 30 of 179
Examine this SELECT statement based on the MARKS table:
SELECT subj1+subj2 total_marks, std_id
FROM marks
WHERE subj1 > AVG(subj1) AND subj2 > AVG(subj2)
ORDER BY total marks;
What is the result of the SELECT statement?
A. The statement executes successfully and returns the student ID and sum of all marks for
each student who obtained more than the average mark in each subject.
B. The statement returns an error at the SELECT clause.
C. The statement returns an error at the WHERE clause.
D. The statement returns an error at the ORDER BY clause.
Answer: C
Explanation:
The statement returns an error at the WHERE clause because group function AVG() cannot be
used in the WHERE clause. Group functions can be used in SELECT clause and GROUP BY
clause. They allow you to perform data operations on several values in a column of data as
though the column were one collective group of data.
Incorrect Answers
A: The statement does not execute successfully because an error will be generated.
B: The statement returns an error at the WHERE, not at the SELECT clause.
D: The statement returns an error at the WHERE, not at the ORDER BY clause.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 122-125
Chapter 3: Advanced Data Selection in Oracle
Question: 47. (C)
Which three SELECT statements display 2000 in the format “$2,000.00”? (Choose three)
A. SELECT TO_CHAR (2000, ‘$#,###.##’)
FROM dual;
B. SELECT TO_CHAR (2000, ‘$0,000.00’)
FROM dual;
C. SELECT TO_CHAR (2000, ‘$9,999.00’)
FROM dual;
D. SELECT TO_CHAR (2000, ‘$9,999.99’)
FROM dual;
E. SELECT TO_CHAR (2000, ‘$2,000.00’)
FROM dual;
F. SELECT TO_CHAR (2000, ‘$N,NNN.NN’)
FROM dual;
Answer: B, C & D
Explanation:
Only queries in answers B, C and D will show result as in the format “$2,000.00”.
Incorrect Answers
A: Oracle error “ORA-01481: invalid number format model” will be generated.
E: Oracle error “ORA-01481: invalid number format model” will be generated.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 31 of 179
F: Oracle error “ORA-01481: invalid number format model” will be generated.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-365
Chapter 8: User Access Control in Oracle
Question: 48. (C)
Examine the description of the EMPLOYEES table:
EMP_ID NUMBER(4) NOT NULL
LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(30).
DEPT_ID NUMBER(2)
JOB_CAT VARCHAR2(30)
SALARY NUMBER(8,2)
Which statement shows the department ID, minimum salary, and maximum salary paid in that
department, only of the minimum salary is less then 5000 and the maximum salary is more than
15000?
A. SELECT dept_id, MIN(salary(, MAX(salary)
FROM employees
WHERE MIN(salary) < 5000 AND MAX(salary) > 15000;
B. SELECT dept_id, MIN(salary), MAX(salary)
FROM employees
WHERE MIN(salary) < 5000 AND MAX(salary) > 15000
GROUP BY dept_id;
C. SELECT dept_id, MIN(salary), MAX(salary)
FROM employees
HAVING MIN(salary) < 5000 AND MAX(salary) > 15000;
D. SELECT dept_id, MIN(salary), MAX(salary)
FROM employees
GROUP BY dept_id
HAVING MIN(salary) < 5000 AND MAX(salary) > 15000;
E. SELECT dept_id, MIN(salary), MAX(salary)
FROM employees
GROUP BY dept_id, salary
HAVING MIN(salary) < 5000 AND MAX(salary) > 15000;
Answer: D
Explanation:
This SELECT statement shows correct result.
Incorrect Answers
A: To provide correct data statement needs also GROUP BY clause.
B: This statement will not provide correct results.
C: HAVING clause can be used only in conjunction with GROUP BY clause.
E: You need only grouping by department, not by salary.
Question: 49. (C)
Which two are true about aggregate functions? (Choose two.)
A. You can use aggregate functions in any clause of a SELECT statement.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 32 of 179
B. You can use aggregate functions only in the column list of the SELECT clause and in the
WHERE clause of a SELECT statement.
C. You can mix single row columns with aggregate functions in the column list of a SELECT
statement by grouping on the single row columns.
D. You can pass column names, expressions, constants, or functions as parameters to an
aggregate function.
E. You can use aggregate functions on a table, only by grouping the whole table as one single
group.
F. You cannot group the rows of a table by more than one column while using aggregate
functions.
Answer: C, D
Explanation:
It is possible to mix single row columns with aggregate functions in the column list of a SELECT
statement by grouping on the single row columns. Also it is acceptable to pass column names,
expressions, constraints, or other functions as parameters to an aggregate function.
Incorrect Answers
A: You cannot use aggregate functions in any clause of a SELECT statement. For example, they
cannot be used with a WHEN statement.
B: It is not possible to use aggregate functions in the WHERE clause of a SELECT statement.
But they can be used with a HAVING clause used after the GROUP BY clause, for example.
E: You don’t need to group the whole table as one single group.
F: It is possible to group more than one column while using aggregate functions.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 122-135
Chapter 3: Advanced Data Selection in Oracle
Question: 50. (C)
Which four statements correctly describe functions that are available in SQL? (Choose four)
A. INSTR returns the numeric position of a named character.
B. NVL2 returns the first non-null expression in the expression list.
C. TRUNCATE rounds the column, expression, or value to n decimal places.
D. DECODE translates an expression after comparing it to each search value.
E. TRIM trims the heading of trailing characters (or both) from a character string.
F. NVL compares two expressions and returns null if they are equal, or the first expression of
they are not equal.
G. NULLIF compares two expressions and returns null if they are equal, or the first expression if
they are not equal.
Answer: A, D, E, G
Explanation:
INSTR returns the numeric position of a named character. DECODE translates an expression
after comparing it to each search value. TRIM trims the heading of trailing characters (or both)
from a character string. NULLIF compares twp expressions and returns null if they are equal, or
the first expression if they are not equal.
Incorrect Answers
B: This statement is not correct. The following is the Syntax for NVL2 function:
NVL2(expr1, expr2, expr3). If expr1 is not null, NVL2 returns expr2. If expr1 is null, NVL2
returns expr3.
C: Command TRUNCATE is used to remove all row data from the table, while leaving the
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 33 of 179
definition of the table intact, including the definition of constraints and any associated database
objects as indexes, constraints, and triggers on the table.
F: NVL returns second parameter value if first one is NULL.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 67-73
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 51. (C)
Examine the structures of the PATIENT, PHYSICIAN, and ADMISSION tables.
PATIENT Table
PATIENT_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
DOB DATE
INS_CODE NUMBER
PHYSICIAN Table
PHYSICIAN _ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (30) NOT NULL
FIRST_NAME VARCHAR2 (25) NOT NULL
LICENSE_NO NUMBER (7) NOT NULL
HIRE_DTAE DATE
ADMISSION Table
PATIENT_ID NUMBER NOT NULL, Primary Key, References PATIENT_ID column of
the PATIENT table
PHYSICIAN_ID NUMBER NOT NULL, Primary Key, References PHYSICIAN_ID column
of the PHYSICIA table
ADMIT_DATE DATE
DISCHG_DATE DATE
ROOM_ID NUMBER Foreign key to ROOM_ID of the ROOM table
Which SQL statement will produce a list of all patients who have more than one physician?
A. SELECT p.patient_id
FROM patient p
WHERE p.patient_id IN (SELECT patient_id
FROM admission
GROUP BY patient_id
HAVING COUNT(*) > 1);
B. SELECT DISTINCT a.patient_id
FROM admission a, admission a2
WHERE a.patient_id = a2.patient_id
AND a.physician_id <> a2.physician_id;
C. SELECT patient_id
FROM admission
WHERE COUNT(physician_id) > 1;
D. SELECT patient_id
FROM patient FULL OUTER JOIN physician;
Answer: B
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 34 of 179
Self join can be used to find the above desired result to list all patients who have more than one
physician as
SELECT DISTINCT a.patient_id
FROM admission a, admission a2
WHERE a.patient_id = a2.patient_id
AND a.physician_id <> a2.physician_id;
Question: 52. (C)
Which clause should you use to exclude group results?
A. WHERE
B. HAVING
C. RESTRICT
D. GROUP BY
E. ORDER BY
Answer: B
Explanation:
HAVING clause is used to weed out unwanted data once the data is grouped using the GROUP
BY statement.
Incorrect Answers
A: WHERE clause cannot be used for this purpose.
C: There is no RESTRICT command in Oracle.
D: GROUP BY cannot be used itself to exclude group results.
E: ORDER BY clause may be used only to sort final results, not to exclude group results.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 133-134
Chapter 3: Advanced Data Selection in Oracle
Question: 53. (C)
In a SELECT statement that includes a WHERE clause, where is the GROUP BY clause placed
in the SELECT statement?
A. Immediately after the SELECT clause
B. Before the WHERE clause
C. Before the FROM clause
D. After the ORDER BY clause
E. After the WHERE clause
Answer: E
Explanation:
The GROUP BY clause can be place only after the WHERE clause, or after FROM clause if there
is no the WHERE clause in the statement.
Incorrect Answers
A: It is not possible to place the GROUP BY clause immediately after the SELECT clause.
B: It is not possible to place the GROUP BY clause before the WHERE clause, it can be done
only after it.
C: It is not possible to place the GROUP BY clause before the FROM clause.
D: It is not possible to place the GROUP BY clause after the ORDER BY clause.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 35 of 179
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 56-67
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 54. (C)
Which two are character manipulation functions? (Choose two.)
A. TRIM
B. REPLACE
C. TRUNC
D. TO_DATE
E. MOD
F. CASE
Answer: A & B
Explanation:
TRIM() and REPLACE() are character manipulation functions.
Incorrect Answers
C: TRUNC(x,y) is arithmetic function, it truncates x to the decimal precision of y. If y is negative, it
truncates to y number of places to the left of the decimal point. This can also be used on DATE
columns.
D: TO_DATE(x,[y]) function converts the non-date value x to a date using the format specified
by y.
E: MOD(x,y) is arithmetic function, the modulus of x, defined in long division as the integer
remainder when x divided by y until no further whole number can be produced.
F: There is no character manipulation function CASE in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 67-93
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 55. (C)
The EMPLOYEES table contains these columns:
LAST_NAME VARCHAR2 (25)
SALARY NUMBER (6,2)
COMMISSION_PCT NUMBER (6)
You need to write a query that will produce these results:
1. Display the salary multiplied by the commission_pct.
2. Exclude employees with a zero commission_pct.
3. Display a zero for employees with a null commission value.
Evaluate the SQL statement:
SELECT LAST_NAME, SALARY*COMMISSION_PCT
FROM EMPLOYEES
WHERE COMMISSION_PCT IS NOT NULL;
What does the statement provide?
A. All of the desired results
B. Two of the desired results
C. One of the desired results
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 36 of 179
D. An error statement
Answer: C
Explanation:
This statement will provide only one of the desired results: display the salary multiplied by the
commission_pct. It will not exclude employees with a zero commission_pct and display a zero for
employees with a null commission value.
Incorrect Answers
A: This statement will provide only one of the desired results, not all.
B: This statement will provide only one of the desired results, not two.
D: This statement will not generate an error, it is correct .
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 25-38
Chapter 1: Overview of Oracle Databases
Question: 56. (C)
Examine the structures of the EMPLOYEE and CURR_ORDER tables as shown below:
EMPLOYEE Table
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (25)
FIRST NAME VARCHAR2 (25)
DEPT_ID NUMBER Foreign key to DEPT_ID column of the
DEPARTMENTS table
JOB_ID NUMBER Foreign key to JOB_ID column of the JOBS table
MGR_ID NUMBER References EMPLOYEE_ID column
SALARY NUMBER (9,2)
COMMISSION NUMBER (7,2)
HIRE_DATE DATE
CURR_ORDER Table
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the
COSTOMERS table
EMPLOYEE_ID NUMBER Foreign key to EMP_ID column of the EMPLOYEES
table
ORDER_DATE DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD NUMBER (5)
You queried the database with this SQL statement:
SELECT a.last_name, a.first_name, a.job_id, NVL(a.commission, 0), b.avgcomm
FROM employee a, (SELECT job_id, AVG(commission) AVGCOMM
FROM employee
WHERE commission IS NOT NULL
GROUP BY job_id) b
WHERE a.job_id = b.job_id
AND a.commission < b.avgcomm;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 37 of 179
Which is a result of this query?
A. The AVG function's DISTINCT keyword must be used in the inner query or the statement will
fail when executed.
B. The employee information displayed will be for employees that have a commission that is
less than the average commission of all employees who have the same job.
C. The employee information displayed will be displayed in numeric order by the JOB_ID and in
alphabetical order by the LAST_NAME where the JOB_IDs are the same.
D. A self join CANNOT be used in an outer query when the inner query is an inline view. The
self join must be placed in the inner query for the statement to execute successfully.
Answer: B
Explanation:
For the above query the information of only those employee will be displayed that have a
commission that is less than the average commission of all employees who have the same job.
Question: 57. (C)
Examine the structures of the EMPLOYEE and CURR_ORDER tables.
EMPLOYEE Table
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCHAR2 (25)
FIRST NAME VARCHAR2 (25)
DEPT_ID NUMBER Foreign key to DEPT_ID column of the
DEPARTMENTS table
JOB_ID NUMBER Foreign key to JOB_ID column of the JOBS table
MGR_ID NUMBER References EMPLOYEE_ID column
SALARY NUMBER (9,2)
COMMISSION NUMBER (7,2)
HIRE_DATE DATE
CURR_ORDER Table
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER Foreign key to CUSTOMER_ID column of the
COSTOMERS table
EMPLOYEE_ID NUMBER Foreign key to EMP_ID column of the EMPLOYEES
table
ORDER_DATE DATE
ORDER_AMT NUMBER (7,2)
SHIP_METHOD NUMBER (5)
To keep your top sales representatives motivated, your company plans to increase the bonuses
of employees. You need to create a SELECT statement that returns the name, bonus, and
maximum order amount associated with each employee for all employees whose bonus is less
than 8 percent of their maximum order amount.
Which SELECT statement should you use?
A. SELECT e.last_name, e.first_name, e.commission, o.maxamt
FROM employee e, (SELECT employee_id, MAX(order_amt) MAXAMT
FROM curr_order
GROUP BY employee_id) o
WHERE e.employee_id = o.employee_id
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 38 of 179
AND e.commission < .08 * o.maxamt;
B. SELECT e.last_name, e.first_name, e.commission, MAX(o.order_amount) MAXAMT
FROM employee e, curr_order o
WHERE e.employee_id = o.employee_id
AND e.commission < .08 * o.maxamt
GROUP BY e.last_name, e.first_name, e.commission;
C. SELECT e.last_name, e.first_name, e.commission, MAX(o.order_amt)
FROM employee e, curr_order
WHERE e.employee_id = o.employee_id
AND e.commission < .08 * (SELECT employee_id, MAX(order_amt) MAXAMT
FROM curr_order
GROUP BY employee_id);
D. SELECT last_name, first_name, commission, max_amt
FROM employee, (SELECT employee_id, MAX(order_amt) MAXAMT
FROM curr_order
GROUP BY employee_id)
WHERE employee.employee_id = curr_order.employee_id
AND commission < .08 * maxamt;
Answer: A
Explanation:
Ans A contain the complete statement that will give you all the desire result needed from the
query.
Question: 58. (C)
The PRODUCT table contains these columns:
PRODUCT_ID NUMBER(9)
PRODUCT_NAME VARCHAR2(25)
COST NUMBER(5,2)
LIST_PRICE NUMBER(5,2)
SUPPLIER_ID NUMBER(9)
You need to display product names, costs, supplier ids, and average list prices for all the
products that cost more than the average cost of products provided by the same supplier. Which
SELECT statement will achieve these results?
A. SELECT product_name, cost, supplier_id, AVG(list_price)
FROM product p, product a
WHERE p.supplier_id = a.supplier_id
GROUP BY product_name, cost, supplier_id;
B. SELECT product_name, cost, p.supplier_id, AVG(list_price)
FROM product p, (SELECT supplier_id, AVG(cost) avg_cost
FROM product
GROUP BY supplier_id) a
WHERE p.cost > a.avg_cost
GROUP BY product_name, cost, p.supplier_id;
C. SELECT product_name, cost, supplier_id, AVG(list_price)
FROM product
WHERE supplier_id IN (SELECT supplier_id, AVG(cost) avg_cost
FROM product
GROUP BY supplier_id)
GROUP BY product_name, cost, supplier_id;
D. SELECT product_name, cost, p.supplier_id, AVG(list_price)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 39 of 179
FROM product p, (SELECT supplier_id, AVG(cost) avg_cost
FROM product
GROUP BY supplier_id) a
WHERE p.supplier_id = a.supplier_id
AND p.cost > a.avg_cost
GROUP BY product_name, cost, p.supplier_id;
Answer: D
Explanation:
For the above desired result the subquery will first find the average cost group by supplier_id and
then making a join this will give the cost of all products that cost more than the average cost as
SELECT product_name, cost, p.supplier_id, AVG(list_price)
FROM product p, (SELECT supplier_id, AVG(cost) avg_cost
FROM product
GROUP BY supplier_id) a
WHERE p.supplier_id = a.supplier_id
AND p.cost > a.avg_cost
GROUP BY product_name, cost, p.supplier_id;
Question: 59. (C)
Which SELECT statement should you use to extract the year from the system date and display it
in the format "1998"?
A. SELECT TO_CHAR(SYSDATE,'yyyy')
FROM dual;
B. SELECT TO_DATE(SYSDATE,'yyyy')
FROM dual;.
C. SELECT DECODE(SUBSTR(SYSDATE, 8), 'YYYY')
FROM dual;
D. SELECT DECODE(SUBSTR(SYSDATE, 8), 'year')
FROM dual;
E. SELECT TO_CHAR(SUBSTR(SYSDATE, 8,2),'yyyy')
FROM dual;
Answer: A
Explanation:
Function TO_CHAR(x, y) converts the value x to a character or converts a date to a character
string using formatting conventions.
Incorrect Answers
B: Function TO_DATE(x,[y]) converts the non-date value x to a date using the format specified
by x.
C: The DECODE function is used as substitution of IF-THEN-ELSE PL/SQL construction in SQL
queries. The SELECT statement provides incorrect syntax of it because it cannot have only
two parameters.
D: The DECODE function is used as substitution of IF-THEN-ELSE PL/SQL construction in SQL
queries. The SELECT statement provides incorrect syntax of it because it cannot have only
two parameters.
E: This statement provide incorrect syntax of TO_CHAR() function: it requires only one
parameter, not two.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 86-87
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 40 of 179
Question: 60. (C)
The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
STREET_ADDRESS VARCHAR2(150)
CITY_ADDRESS VARCHAR2(50)
STATE_ADDRESS VARCHAR2(50)
PROVINCE_ADDRESS VARCHAR2(50)
COUNTRY_ADDRESS VARCHAR2(50)
POSTAL_CODE VARCHAR2(12)
CUSTOMER_PHONE VARCHAR2(20)
The CUSTOMER_ID column is the primary key for the table.
Which two statements find the number of customers? (Choose two.)
A. SELECT TOTAL(*)
FROM customers;
B. SELECT COUNT(*)
FROM customers;
C. SELECT TOTAL(customer_id)
FROM customers;
D. SELECT COUNT(customer_id)
FROM customers;
E. SELECT COUNT(customers)
FROM customers;
F. SELECT TOTAL(customer_name)
FROM customers;
Answer: B & D
Explanation:
These statements provide correct syntax and semantics to show the number of customers.
Function COUNT() can be used with substitution symbol of all columns “*” or just with one column
name. Last query will be processed a little bit faster.
Incorrect Answers
A: There is no TOTAL() function in Oracle.
C: There is no TOTAL() function in Oracle.
E: You cannot table name as a parameter of COUNT() function.
F: There is no TOTAL() function in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 123-125
Chapter 3: Advanced Data Selection in Oracle
Question: 61. (C)
Examine the structures of the EMPLOYEES and TAX tables.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 41 of 179
EMPLOYEES
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_NAME VARCHAR2 (30)
JOB_ID VARCHAR2 (20)
SALARY NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the
DEPARTMENTS table
TAX
MIN_SALARY NUMBER
MAX_SALARY NUMBER
TAX_PERCENT NUMBER Percentage tax for given salary range
You need to find the percentage tax applicable for each employee. Which SQL statement would
you use?
A. SELECT employee_id, salary, tax_percent
FROM employees e, tax t
WHERE e.salary BETWEEN t.min_salary AND t.max_salary;
B. SELECT employee_id, salary, tax_percent
FROM employees e, tax t.
WHERE e.salary > t.min_salary, tax_percent
C. SELECT employee_id, salary, tax_percent
FROM employees e, tax t
WHERE MIN(e.salary) = t.min_salary
AND MAX(e.salary) = t.max_salary
D. You cannot find the information because there is no common column between the two tables.
Answer: A
Explanation:
You can find the percentage tax applicable for each employee by using SQL statement in answer
A.
Incorrect Answers
B: Syntax “WHERE e.salary > t.min_salary, tax_percent” is incorrect.
C: Functions, like MIN() and MAX(), cannot be used in the WHERE clause.
D: The SQL statement from the answer A will provide requested information.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 98-103
Chapter 3: Advanced Data Selection in Oracle
Question: 62. (C)
Examine the data in the WORKORDER table.
WO_ID CUST_ID REQUIRED_DT COMPLE_DT AMOUNT
1 1 04-DEC-2001 02-DEC-01 520.32
2 1 02-JAN-2002
3 2 17-JAN-2002
4 2 20-JAN-2002 05-JAN-2002 274.11
6 3 14-JAN-2001 13-JAN-2002 400.00
7 3 04-FEB-2002
8 4 01-FEB-2002
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 42 of 179
9 5 14-JAN-2002
The WORKORDER table contains these columns:
WO_ID NUMBER PK
CUST_ID NUMBER
REQUIRED_DT DATE
COMPL_DT DATE
AMOUNT NUMBER(7,2)
Which statement regarding the use of aggregate functions on the WORKORDER table is true?
A. Using the SUM aggregate function with the AMOUNT column is allowed in any portion of a
SELECT statement.
B. Using the AVG aggregate function with any column in the table is allowed.
C. Using the SUM aggregate function on the AMOUNT column will result in erroneous results
because the column contains null values.
D. Grouping on the REQUIRED_DT and COMPL_DT columns is NOT allowed.
E. Using the AVG aggregate function on the AMOUNT column ignores null values.
F. Using the MIN aggregate function on the COMPL_DT column will return a null value.
Answer: E
Explanation:
All group functions except COUNT ignore null values. Using AVG aggregate function on the
AMOUNT column ignores null values.
Question: 63.
The INVENTORY table contains these columns:
ID_NUMBER NUMBER PK
CATEGORY VARCHAR2(10)
LOCATION NUMBER
DESCRIPTION VARCHAR2(30)
PRICE NUMBER(7,2)
QUANTITY NUMBER
You want to return the total of the extended amounts for each item category and location,
including only those inventory items that have a price greater than $100.00. The extended
amount of each item equals the quantity multiplied by the price. Which SQL statement will return
the desired result?
A. SELECT category, SUM(price * quantity) TOTAL, location
FROM inventory
WHERE price > 100.00
GROUP BY category;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 43 of 179
B. SELECT category, location, SUM(price)
FROM inventory
WHERE price > 100.00
GROUP BY category, location;
C. SELECT category, SUM(price * quantity) TOTAL, location
FROM inventory
WHERE price > 100.00;
D. SELECT category, SUM(price * quantity) TOTAL, location
FROM inventory
WHERE price > 100.00
GROUP BY category, location;
Answer: D
Explanation:
You can find total extended amount by using SUM group by function and it can be grouped by
catergory and then location with GROUP BY clause.
Question: 64. (C)
The EVENT table contains these columns:
EVENT_ID NUMBER
EVENT_NAME VARCHAR2(30)
EVENT_DESC VARCHAR2(100)
EVENT_TYPE NUMBER
LOCATION_ID NUMBER
You have been asked to provide a report of the number of different event types at each location.
Which SELECT statement will produce the desired result?
A. SELECT UNIQUE(location_id), COUNT(event_type)
FROM event
GROUP BY location_id;
B. SELECT COUNT(*), DISTINCT(location_id)
FROM event;
C. SELECT DISTINCT (event_type)
FROM event
GROUP BY location_id;
D. SELECT location_id, COUNT(DISTINCT event_type)
FROM event
GROUP BY location_id;
E. SELECT location_id, MAX(DISTINCT event_type)
FROM event
GROUP BY location_id;
Answer: D
Explanation:
Unique number of event types at each location can be find by using COUNT to count the number
of events and then GROUP BY clause can be used with locatio_id column to make it location
wise.
Question: 65. (C)
Which two statements about the evaluation of clauses in a SELECT statement are true? (Choose
two.)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 44 of 179
A. The Oracle Server will evaluate a HAVING clause before a WHERE clause.
B. The Oracle Server will evaluate a WHERE clause before a GROUP BY clause.
C. The Oracle Server will evaluate a GROUP BY clause before a HAVING clause.
D. The Oracle Server will evaluate an ORDER BY clause before a WHERE clause.
E. The Oracle Server will evaluate an ORDER BY clause before a HAVING clause.
Answer: B & C
Explanation:
In SELECT statement WHERE clause comes after the FROM clause and before GROUP By
clause while HAVING clause use to restrict the data group wise and it comes after the GROUP
BY clause and ORDER BY clause comes after at end of SELECT statement.
Question: 66. (C)
Examine the structures of the EMPLOYEE and DEPARTMENT tables:
EMPLOYEE
------------------
EMP_ID NUMBER NOT NULL PK
NAME VARCHAR(30) NOT NULL
FNAME VARCHAR(25) NOT NULL
DEPT_NO NUMBER
TITLE VARCHAR2(25)
DEPARTMENT
------------------------
DEPT_ID NUMBER NOT NULL PK
DEPT_NAME VARCHAR2(25)
You need to produce a list of departments, including the department names, that have more than
three administrative assistants. Which SELECT statement will produce the desired result?
A. SELECT dept_name
FROM employee JOIN department
ON employee.dept_id = department.dept_id
WHERE UPPER(title) = 'ADMINISTRATIVE ASSISTANT'
GROUP BY dept_name
HAVING emp_id > 3;
B. SELECT dept_name
FROM employee
GROUP BY dept_no
HAVING LOWER(title) = 'administrative assistant' AND COUNT(*) > 3;
C. SELECT dept_name
FROM employee NATURAL JOIN department
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
D. SELECT dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
AND COUNT(*) > 3;
E. SELECT d.dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 45 of 179
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
F. SELECT d.dept_name
FROM e.employee JOIN d.department
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;
Answer: E
Explanation:
To obtain the above desired result LOWER function is used to used with the TITILE column value
to find it whether values stored is in the lower case or in upper case it will convert it in to lower
and compare it. COUNT function will count the whole values and restricted the result to three
values by using HAVING clause.
Question: 67. (C)
Which two tasks can you perform by using the TO_CHAR function? (Choose two)
A. Convert 10 to ‘TEN’
B. Convert ‘10’ to 10
C. Convert ‘10’ to ‘10’
D. Convert ‘TEN’ to 10
E. Convert a date to a character expression
F. Convert a character expression to a date
Answer: C & E
Explanation:
TO_CHAR(x) function is used to convert the value x to a character or converts a date to a
character string using formatting conventions.
Incorrect Answers
A: This function cannot convert the number to the string representing number spelled out.
B: TO_CHAR() function cannot convert the character value to a number. TO_NUMBER() function
does this.
D: This function is not able to convert the string representing number spelled out to the number
itself.
F: TO_CHAR() function cannot convert a character expression to a date. TO_DATE() function
does this.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 86-87
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 68. (C)
Examine the data in the LINE_ITEM table.
LINE_ITEM_ID ORDER_ID PRODUCT_ID QUANTITY
2 1494 A-2356 7
3 1533 A-7849 18
6 1589 C-589 33
1 1533 A-3209 100
2 1533 A-3210 1
4 1494 Z-78 1
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 46 of 179
10 1588 C-555 250
3 1494 Z-79 5
You query the database and return the value 23. Which script did you use?
A. SELECT SUBSTR(product_id, 3)
FROM line_item
WHERE line_item_id = 2
AND order_id = 1494;
B. SELECT SUBSTR(product_id, 3, -2)
FROM line_item
WHERE line_item_id = 2
AND order_id = 1494;
C. SELECT SUBSTR(product_id, -3, 2)
FROM line_item
WHERE line_item_id = 2
AND order_id = 1494;
D. SELECT SUBSTR(product_id, 3, 2)
FROM line_item
WHERE line_item_id = 2
AND order_id = 1494;
Answer: D
Explanation:
A SUBSTR function can be used statement to extract a string of determined length.
Question: 69. (C)
Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12?
A. SELECT ename, salary*12 ‘Annual Salary’
FROM employees;
B. SELECT ename, salary*12 “Annual Salary”
FROM employees;
C. SELECT ename, salary*12 AS Annual Salary
FROM employees;
D. SELECT ename, salary*12 AS INITCAP(“ANNUAL SALARY”)
FROM employees
Answer: B
Explanation:
This SQL statement provides correct syntax to generate the alias Annual Salary for the calculated
column SALARY*12.
Incorrect Answers
A: Alias can be surrounded with double quotation marks, not with single. Oracle error will be
generated in this case.
C: Alias needs to be surrounded with double quotation marks, it cannot just follow by the AS
keyword.
D: You cannot use any function as alias, so this SQL statement will fail.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 33-35
Chapter 1: Overview of Oracle Databases
Question: 70. (C)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 47 of 179
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
DEPARTMENT_ ID NUMBER
SALARY NUMBER
What is the correct syntax for an inline view?
A. SELECT a.last_name, a.salary, a.department_id, b.maxsal
FROM employees a,
(SELECT department_id, max(salary)maxsal
FROM employees
GROUP BY department_id) b
WHERE a.department_id = b.department_id
AND a.salary < b.maxsal;
B. SELECT a.last name, a.salary, a.department_id
FROM employees a
WHERE a.department_id IN
(SELECT department_id
FROM employees b
GROUP BY department_id having salary =
(SELECT max(salary) from employees))
C. SELECT a.last_name, a.salary, a.department_id
FROM employees a
WHERE a.salary =
(SELECT max(salary)
FROM employees b
WHERE a.department_id = b.department_id);
D. SELECT a.last_name, a.salary, a.department_id
FROM employees a
WHERE (a.department_id, a.salary) IN
(SELECT department_id, a.salary) IN
(SELECT department_id max(salary)
FROM employees b
GROUP BY department_id
ORDER BY department_id);
Answer: A
Explanation:
This SQL statement shows correct syntax to build inline views. You must enclose the query text
for the inline view in parentheses and also give a label for the inline view so that columns in it can
be referenced later. In answer A inline view is marked as B.
Incorrect Answers
B: This SQL statement will fail because it is not correct syntax for inline views. There is no a label
for this inline view also.
C: This SQL statement will fail because it is not correct syntax for inline views. There is no a label
for this inline view also.
D: This SQL statement will fail because it is not correct syntax for inline views. There is no a label
for this inline view also.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 162-165
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 48 of 179
Chapter 4: Subqueries
Question: 71. (C)
Which clause would you use in a SELECT statement to limit the display to those employees
whose salary is greater then 5000?
A. ORDER BY SALARY > 5000.
B. GROUP BY SALARY > 5000
C. HAVING SALARY > 5000
D. WHERE SALARY > 5000
Answer: D
Explanation:
You need to use the WHERE clause to limit the display to those employees whose salary is
greater then 5000.
Incorrect Answers
A: The ORDER BY clause will just sort data, but it will not limit them.
B: You cannot use the GROUP BY clause with conditions. Oracle error will be generated.
C: The HAVING clause may be used only in conjunction with the GROUP BY clause.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 61-67
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 72. (C)
You need to calculate the total of all salaries in the accounting department. Which group function
should you use?
A. MAX
B. MIN
C. SUM
D. COUNT
E. TOTAL
F. LARGEST
Answer: C
Explanation:
Function SUM(x) calculates the sum of all values in column x in all rows returned by the SELECT
statement.
Incorrect Answers
A: Function MAX(x) determines the maximum value in column x for all rows returned by the
SELECT statement.
B: Function MIN(x) determines the minimum value in column x for all rows returned by the
SELECT statement.
D: Function COUNT(x) counts the number of non-NULL values returned by the SELECT
statement for column x.
E: There is no TOTAL() function in Oracle.
F: There is no LARGEST() function in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 122-126
Chapter 3: Advanced Data Selection in Oracle
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 49 of 179
Question: 73. (C)
Which SELECT statement will the result ‘elloworld’ from the string ‘HelloWorld’?
A. SELECT SUBSTR( ‘HelloWorld’,1) FROM dual;
B. SELECT INITCAP(TRIM (‘HelloWorld’, 1,1)) FROM dual;
C. SELECT LOWER(SUBSTR(‘HellowWorld’, 1, 1) FROM dual;
D. SELECT LOWER(SUBSTR(‘HelloWorld’, 2, 1) FROM dual;
E. SELECT LOWER(TRIM (‘H’ FROM ‘HelloWorld’)) FROM dual;
Answer: E
Explanation:
TRIM function accept a string describing the data you would like to trim from a column value. It
can trim from both side of column value i.e. left and right. In the following statement this function
will trim as
SELECT LOWER(TRIM (‘H’ FROM ‘HelloWorld’)) FROM dual;
From the above statement trim function will remove the character ‘H’ from ‘HelloWorld’ and
LOWER function will convert the remaining character to lower case.
Question: 74. (C)
Evaluate this SQL statement:
SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct)
+ (s.sales amount * (.35 * e.bonus)) AS CALC_VALUE
FROM employees e, sales s
WHERE e.employee_id = s.emp_id;
What will happen if you remove all the parentheses from the calculation?
A. The value displayed in the CALC_VALUE column will be lower.
B. The value displayed in the CALC_VALUE column will be higher.
C. There will be no difference in the value displayed in the CALC_VALUE column.
D. An error will be reported.
Answer: C
Explanation:
There will be no difference in the value displayed in the CALC_VALUE column because not
arithmetic operations or usage of alias for the calculated expression in the SELECT clause will
not cause change the value appearance.
Incorrect Answers
A: There will be no difference in the value displayed in the CALC_VALUE column.
B: There will be no difference in the value displayed in the CALC_VALUE column.
D: There is no error in this statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 29-34
Chapter 1: Overview of Oracle Databases
Question: 75. (C)
Which script displays '01-JAN-02' when the ENROLL_DATE value is '01-JUL-01'?
A. SELECT ROUND(enroll_date, 'DAY')
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 50 of 179
FROM student;
B. SELECT ROUND(enroll_date, 'YEAR')
FROM student;
C. SELECT ROUND(enroll_date, 'MONTH')
FROM student;
D. SELECT ROUND(TO_CHAR(enroll_date, 'YYYY'))
FROM student;
Answer: B
Explanation:
ROUND function will round a value to the next higher value. In the above given scenario the
ENROLL_DATE will be round to the next year as the enroll_date is higher than 30-jun-01 so it will
be rounded to the next year by specifying the YEAR option with the ROUND function.
Question: 76. (C)
Which three functions can be used to manipulate character, number, or date column values?
(Choose three.)
A. CONCAT
B. ROUND
C. TRUNC
D. RPAD
E. INSTR
Answer: A, D & E
Explanation:
CONCAT , ROUND and INSTR are three single row function that can be used to manipulate
character, number and data column values. INSTR finds numeric position of named character
CONCAT function it concatenate the first character value to the second value and ROUND
fucnion will round the value to n decimal.
Question: 77. (C)
A new standard has been adopted in your department that all codes that contain only 3
characters must have a dash (-) and two character values appended to them. Which function can
be used in your query to restrict the data displayed to only those codes containing 3 characters?
A. REPLACE
B. SUBSTR
C. LENGTH
D. RPAD
Answer: C
Explanation:
LENGTH function returns the number of characters in the value so you can restrict the data
displayed to specified character by using LENGTH function.
Question: 78. (C)
Which statement concerning SQL functions is true?
A. Character functions can return character or number values.
B. Conversion functions convert a column definition from one data type to another data type.
C. Single-row functions can only be used in SELECT and WHERE clauses.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 51 of 179
D. All date functions return DATE data type values.
Answer: A
Explanation:
Single row character functions accept character data as input and can return both character and
number values. Character functions are case conversion function and character manipulation
functions
Question: 79. (C)
The STUDENT_GRADES table has these columns:
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
The registrar has asked for a report on the average grade point average (GPA) for students
enrolled during semesters that end in the year 2000. Which statement accomplish this?
A. SELECT AVERAGE(gpa)
FROM student_grades
WHERE semester_end > ’01-JAN-2000’ and semester end < 31-
DEC-2000’;
B. SELECT COUNT(gpa)
FROM student grades
WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-
DEC-2000’;
C. SELECT MID(gpa)
FROM student grades
WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-
DEC-2000’;.
D. SELECT AVG(gpa)
FROM student_grades
WHERE semester_end BETWEEN ’01-JAN-2000’ and ’31.DEC.2000’;
E. SELECT SUM(gpa)
FROM student grades
WHERE semester_end > ’01-JAN-2000’ and semester end < ’31-
DEC-2000’;
F. SELECT MEDIAN(gpa)
FROM student_grades
WHERE semester end > ’01-JAN-2000’ and semester end < ’31-
DEC-2000’;
Answer: D
Explanation:
Statement in this answer will show correct result, using function AVG(). This function takes the
values for a single column on all rows returned by the query and calculates the average value for
that column.
Incorrect Answers
A: There is no AVERAGE() function in Oracle.
B: COUNT() will calculate number of row, not an average grade point.
C: MIN() function will calculate minimum grade for all students enrolled during semesters that end
in the year 2000.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 52 of 179
E: SUM() will calculate sum of all grade points for all students enrolled during semesters that end
in the year 2000.
F: There is no MEDIAN() function in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 123-125
Chapter 3: Advanced Data Selection in Oracle
Question: 80. (C)
Evaluate the SQL statement:
1 SELECT a.emp_name, a.sal, a.dept_id, b.maxsal
2 FROM employees a,
3 (SELECT dept_id, MAX(sal) maxsal
4. FROM employees
5 GROUP BY dept_id) b
6 WHERE a.dept_id = b.dept_id
7 AND a.sal < b.maxsal;
What is the result of the statement?
A. The statement produces an error at line 1.
B. The statement produces an error at line 3.
C. The statement produces an error at line 6.
D. The statement returns the employee name, salary, department ID, and maximum salary
earned in the department of the employee for all departments that pay less salary then the
maximum salary paid in the company.
E. The statement returns the employee name, salary, department ID, and maximum salary
earned in the department of the employee for all employees who earn less than the maximum
salary in their department.
Answer: E
Explanation:
The statement returns the employee name, salary, department ID, and maximum salary earned in
the department of the employee for all employees who earn less than the maximum salary in their
department. This query is example of an inline view which is the sub-query in the FROM clause of
the main query. The sub-query can be a SELECT statement that utilizes joins, the GROUP BY
clause, or the ORDER BY clause.
Incorrect Answers
A: The statement does not produce an error at line 1.
B: The statement does not produce an error at line 3.
C: The statement does not produce an error at line 6.
D: The statement returns the employee name, salary, department ID, and maximum salary
earned in the department of the employee for all EMPLOYEES, NOT DEPARTMENTS, who earn
less than the maximum salary in their department.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 161-165
Chapter 4: Subqueries
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 53 of 179
Question: 81. (C)
The EMP table has these columns:
ENAME VARCHAR2(35)
SALARY NUMBER(8,2)
HIRE_DATE DATE
Management wants a list of names of employees who have been with the company for more than
five years. Which SQL statement displays the required results?
A. SELECT ENAME
FROM EMP
WHERE SYSDATE-HIRE_DATE > 5;
B. SELECT ENAME
FROM EMP
WHERE HIRE_DATE-SYSDATE > 5;
C. SELECT ENAME
FROM EMP
WHERE (SYSDATE-HIRE_DATE)/365 > 5;
D. SELECT ENAME
FROM EMP
WHERE (SYSDATE-HIRE_DATE)* 365 > 5;
Answer: C
Explanation:
Expression SYSDATE-HIRE_DATE will show number of days after date of hiring employee, so
you need to divide result of expression on 365 and this compare result with 5.
Incorrect Answers
A: This query returns all employees who were hired more than 5 days ago.
B: This query will not return any record because result of HIRE_DATE-SYSDATE expression will
be negative number.
D: You need to divide, not to multiply, SYSDATE-HIRE_DATE on the number of days in 1 year.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 81-85
Chapter 2: Limiting, Sorting, and Manipulating Return Data
Question: 82. (C)
Which SELECT statement will the result ‘ello world’ from the string ‘Hello World’?
A. SELECT SUBSTR( ‘Hello World’,1) FROM dual;
B. SELECT INITCAP(TRIM (‘Hello World’, 1,1)) FROM dual;
C. SELECT LOWER(SUBSTR(‘Hello World’, 1, 1) FROM dual;
D. SELECT LOWER(SUBSTR(‘Hello World’, 2, 1) FROM dual;
E. SELECT LOWER(TRIM (‘H’ FROM ‘Hello World’)) FROM dual;
Answer: E
Explanation:
This statement will return correct result because function TRIM() will trim letter ‘H’ in the ‘Hello
World’ and function LOWER() will return data in string in lowercase.
Incorrect Answers
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 54 of 179
A: This statement will return sub-string starting at the character in position number Y to the end.
B: There is incorrect syntax in the TRIM() function.
C: There is incorrect syntax in that statement because of absence right bracket.
D: There is incorrect syntax in that statement because of absence right bracket.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 67-69
Chapter 2: Limiting, Sorting, and Manipulating Return Data.
Question: 83. (C)
Evaluate the SQL statement:
SELECT ROUND(45.953, -1), TRUNC(45.936, 2)
FROM dual;
Which values are displayed?
A. 46 and 45
B. 46 and 45.93
C. 50 and 45.93
D. 50 and 45.9
E. 45 and 45.93
F. 45.95 and 45.93
Answer: C
Explanation :
ROUND (45.953,-1) will round value to 1 decimal places to the left.
TRUNC (45.936,2) will truncate value to 2 decimal
The answer will be 50 and 45.93
Incorrect Answers :
A. Does not meet round and truncate functions
B. Does not meet round functions
D. Does not meet truncate functions
E. Does not meet round functions
F. Does not meet round functions
Reference:
Introduction to Oracle9i : SQL, Oracle University Student Guide, Single-Row functions, p. 3-13
Question: 84. (C)
The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER (4) NOT NULL
CUSTOMER_NAME VARCHAR2 (100) NOT NULL
STREET_ADDRESS VARCHAR2 (150)
CITY_ADDRESS VARHCAR2 (50)
STATE_ADDRESS VARCHAR2 (50)
PROVINCE_ADDRESS VARCHAR2 (50)
COUNTRY_ADDRESS VARCHAR2 (50)
POSTAL_CODE VARCHAR2 (12)
CUSTOMER_PHONE VARCHAR2 (20)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 55 of 179
The CUSTOMER_ID column is the primary key for the table. You need to determine how
dispersed your customer base is. Which expression finds the number of different countries
represented in the CUSTOMERS table?
A. COUNT(UPPER(country_address))
B. COUNT(DIFF(UPPER(country_address)))
C. COUNT(UNIQUE(UPPER(country_address)))
D. COUNT DISTINTC UPPER(country_address)
E. COUNT(DISTINTC (UPPER(country_address)))
Answer: E
Question: 85. (C)
You want to use single row function in your SQL statements which three of the following are
number functions? (Choose three).
A. SINH
B. TO_NUMBER.
C. SQRT.
D. ROUND.
Answer: A, C & D
Explanation:
Only To_number is non numeric functions as this is a conversion function. SINH, SQRT &
ROUND are all numeric functions.
Question: 86. (C)
You are using single row function in a SELECT statement which function can best be
catergorized as similar in function to an IF-THEN-ELSE statement?
A. SQRT
B. DECODE
C. NEW_TIME
D. ROWIDTOCHAR.
Answer: B
Explanation:
DECODE function acts like an IF-THEN-ELSE clause in your sql statement.
Question: 87. (C)
Which of the following functions are available in SQL? (Choose four)
A. INSTR.
B. NVL2.
C. TRUNCATE.
D. DECODE.
E. TRIM.
F. NVL.
G. NULLIF.
Answer: A, D, E & G
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 56 of 179
INSTR is a single row function that returns the numeric position of character in a given value
DECODE function enables a powerful transformation of data from one value to another. This
function works on the same principle as the if-then-else statement does in PL/SQL or in other
common programming language.
TRIM function can trim character from left or right side of character or from both.
NULIFF compares two expressions and return null if they are equal or the first expression if they
are not equal.
Question: 88.(D)
Examine the structure of the EMPLOYEES and DEPARTMENTS tables:
EMPLOYEES
Column name Data type Remarks
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_NAME VARCHAR2 (30)
JOB_ID VARCHAR2 (20)
SALARY NUMBER
MGR_ID NUMBER References EMPLOYEE_ID COLUMN
DEPARTMENT ID NUMBER Foreign key to DEPARTMENT ID column
of the DEPARTMENTS table
DEPARTMENTS
Column name Data type Remarks
DEPARTMENT_ID NUMBER NOT NULL, Primary Key
DEPARTMENT_NAME VARCHAR2(30)
MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table
Evaluate this SQL statement:
SELECT employee_id, e.department_id, department_name,
salary
FROM employees e, departments d
WHERE e.department_id = d.department_id;
Which SQL statement is equivalent to the above SQL statement?
A. SELECT employee_id, department_id, department_name,
salary.
FROM employees
WHERE department_id IN (SELECT department_id
FROM departments);
B. SELECT employee_id, department_id, department_name,
salary
FROM employees
NATURAL JOIN departments;
C. SELECT employee_id, d.department_id, department_name,
salary
FROM employees e
JOIN departments d
ON e.department_id = d.department_id;
D. SELECT employee_id, department_id, department_name,
Salary
FROM employees
JOIN departments
USING (e.department_id, d.department_id);
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 57 of 179
Answer: C
Explanation:
This query shows correct JOIN ON clause syntax and provides equivalent to the above SQL
statement.
Incorrect Answers
A: This statement will show data only for the EMPLOYEES table with records that have
department ID from DEPARTMENTS table, not join result of two tables.
B: NATURAL join selects rows from the tables that have equal values in all matched columns
(same column names). If the columns having the same names have different datatypes, an
error is returned.
D: There is incorrect usage of JOIN clause with USING keyword.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 112-114
Chapter 3: Advanced Data Selection in Oracle
Question: 89. (D)
Examine the data in the EMPLOYEES and DEPARTMENTS tables.
EMPLOYEES
LAST_NAME DEPARTMENT_ID SALARY
Getz 10 3000
Davis 20 1500
King 20 2200
Davis 30 5000
Kochhar 5000
DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME
10 Sales
20 Marketing
30 Accounts
40 Administration
You want to retrieve all employees, whether or not they have matching departments in the
departments table. Which query would you use?
A. SELECT last_name, department_name
FROM employees , departments(+);
B. SELECT last_name, department_name
FROM employees JOIN departments (+);
C. SELECT last_name, department_name
FROM employees(+) e JOIN departments d
ON (e.department_id = d.department_id);
D. SELECT last_name, department_name
FROM employees e
RIGHT OUTER JOIN departments d ON (e.department_id =
d.department_id);
E. SELECT last_name, department_name
FROM employees(+) , departments
ON (e.department_id = d.department_id);
F. SELECT last_name, department_name
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 58 of 179
FROM employees e LEFT OUTER
JOIN departments d ON (e.department_id = d.department_id);
Answer: F
Explanation:
Answer F is correct. This query shows correct syntax to retrieve all employees, whether or not
they have matching departments in the department table. Oracle9i extends its compliance with
ANSI/ISO by supporting that standard’s requirements for outer join syntax and semantics.
Incorrect Answers
A: This query uses “+” to create outer join as it was in Oracle8i, but it requires also usage of
WHERE clause in SELECT statement.
B: The JOIN clause cannot be used with in conjunction with “+”: syntax is incorrect.
C: The JOIN clause cannot be used with in conjunction with “+”: syntax is incorrect.
D: This statement requires LEFT OUTER JOIN, not RIGHT OUTER JOIN.
E: This query uses incorrect syntax with “+” and ON to create outer join.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 112-114
Chapter 3: Advanced Data Selection in Oracle
Question: 90. (D)
In which case would you use a FULL OUTER JOIN?
A. Both tables have NULL values.
B. You want all unmatched data from one table.
C. You want all matched data from both tables.
D. You want all unmatched data from both tables.
E. One of the tables has more data than the other.
F. You want all matched and unmatched data from only one table.
Answer: D
Explanation:
Oracle9i also makes it possible for you to easily execute a full outer join, including all records
from the tables that would have been displayed if you had used both LEFT OUTER JOIN or
RIGTH OUTER JOIN clauses.
Incorrect Answers
A: You will not use a FULL OUTER JOIN if both tables have NULL values.
B: You will not use a FULL OUTER JOIN if you want all unmatched data from one table.
Only LEFT OUTER JOIN or RIGTH OUTER JOIN needs to be used.
C: You want all unmatched, not matched, data from both tables.
E: It is not a criterion to use a FULL OUTER JOIN if one of the tables has more data than the
other.
F: You want all unmatched, not matched data or a combination of matched and unmatched data,
from both tables, not one table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 109-118
Chapter 3: Advanced Data Selection in Oracle
Question: 91. (D)
Which three are true regarding the use of outer joins? (Choose three.)
A. You cannot use IN operator in a condition that involves an outerjoin.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 59 of 179
B. You use (+) on both sides of the WHERE condition to perform an outerjoin.
C. You use (*) on both sides of the WHERE condition to perform an outerjoin.
D. You use an outerjoin to see only the rows that do not meet the join condition.
E. In the WHERE condition, you use (+) following the name of the column in the table without
matching rows, to perform an outerjoin.
F. You cannot link a condition that is involved in an outerjoin to another condition by using the
OR operator.
Answer: D, E & F
Explanation:
You can use an outerjoin to see only the rows that do not meet the join condition. In the WHERE
condition, you use (+) following the name of the column in the table without matching rows, to
perform an outerjoin. You cannot link a condition that is involved in an outerjoin to another
condition by using the OR operator.
Incorrect Answers
A: You can use IN operator in a condition that involves an outerjoin.
B: You use (+) following the name of the column in the table without matching rows, but not on
both sides of the WHERE condition to perform an outerjoin.
C: You don’t use (*) to define outerjoin operation.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 109-118
Chapter 3: Advanced Data Selection in Oracle
Question: 92. (D)
What is true about joining tables through an equijoin?
A. You can join a maximum of two tables through an equijoin.
B. You can join a maximum of two columns through an equijoin.
C. You specify an equijoin condition in the SELECT or FROM clauses of a SELECT statement.
D. To join two tables through an equijoin, the columns in the join condition must be primary key
and foreign key columns.
E. You can join n tables (all having single column primary keys) in a SQL statement by
specifying a minimum of n-1 join conditions.
Answer: E
Explanation:
For N joined tables using Oracle or ANSI/ISO syntax for table joins, you need at least N-1
equijoin conditions in the WHERE clause of your SELECT statement or N-1 JOIN table_name ON
join_condition clauses in order to avoid a Cartesian product, respectively.
Incorrect Answers
A: There is no maximum on two tables to join them through an equijoin.
B: There is no maximum on two columns to join them through an equijoin.
C: You can specify an equijoin condition only in the FROM clauses of a SELECT statement.
D: There is no limitation about primary key and foreign key for the columns to use them for an
equijoin.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 99-107
Chapter 3: Advanced Data Selection in Oracle
Question: 93. (D)
Examine the structure of the EMPLOYEES, DEPARTMENTS, and TAX tables.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 60 of 179
EMPLOYEES
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_NAME VARCHAR2 (30)
JOB_ID VARCHAR2 (20)
SALARY NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of
the DEPARTMENTS table
DEPARTMENTS
DEPARTMENT_ID NUMBER NOT NULL, Primary Key
DEPARTMENT_NAME VARCHAR2 |30|
MGR_ID NUMBER References MGR_ID column of the
EMPLOYEES table
TAX
MIN_SALARY NUMBER
MAX_SALARY NUMBER
TAX_PERCENT NUMBER
For which situation would you use a nonequijoin query?
A. To find the tax percentage for each of the employees.
B. To list the name, job id, and manager name for all the employees.
C. To find the name, salary, and department name of employees who are not working with
Smith.
D. To find the number of employees working for the Administrative department and earning less
then 4000.
E. To display name, salary, manager ID, and department name of all the employees, even if the
employees do not have a department ID assigned.
Answer: A
Explanation:
You will use a nonequijoin query to find the tax percentage for each of the employees because
you will check range of salaries without usage of equality operations in a comparison joining data
from two tables.
Incorrect Answers
B: You will use equijoin query because EMPLOYEES and DEPARTMENTS tables will be joined
with equality operator.
C: It will be equijoin query because EMPLOYEES and DEPARTMENTS tables will be joined with
equality operator.
D: You will use equijoin query because EMPLOYEES and DEPARTMENTS tables will be joined
with equality operator.
E: It will be equijoin query because of equality operator in join condition of two tables.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 99-107
Chapter 3: Advanced Data Selection in Oracle
Question: 94. (D)
Examine the structure of the EMPLOYEES, DEPARTMENTS, and LOCATIONS tables.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 61 of 179
EMPLOYEES
EMPLOYEE_ID NUMBER NOT NOT NULL, Primary Key
EMP_NAME VARCHAR2 (30)
JOB_ID VARCHAR2 (20)
SALARY NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID
column of the DEPARTMENTS table
DEPARTMENTS
DEPARTMENT_ID NUMBER NOT NULL, Primary Key
DEPARTMENT_NAME VARCHAR2
(30)
MGR_ID NUMBER References NGR_ID column of the EMPLOYEES
table
LOCATION_ID NUMBER Foreign key to LOCATION_ID column of
theLOCATIONS table
LOCATIONS
LOCATION_ID NUMBER NOT NULL, Primary Key
CITY VARCHAR2 |30)
Which two SQL statements produce the name, department name, and the city of all the
employees who earn more then 10000? (Choose two)
A. SELECT emp_name, department_name, city
FROM employees e
JOIN departments d
USING (department_id)
JOIN locations 1
USING (location_id)
WHERE salary > 10000;
B. SELECT emp_name, department_name, city
FROM employees e, departments d, locations 1
JOIN ON (e.department_id = d.department id)
AND (d.location_id =1.location_id)
AND salary > 10000;
C. SELECT emp_name, department_name, city
FROM employees e, departments d, locations 1
WHEREsalary > 10000;
D. SELECT emp_name, department_name, city
FROM employees e, departments d, locations 1
WHEREe.department_id = d.department_id
AND d.location_id = 1.location_id
AND salary > 10000;
E. SELECT emp_name, department_name, city
FROM employees e
NATURAL JOIN departments, locations
WHEREsalary > 10000;
Answer: B & D
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 62 of 179
Explanation:
These statements show correct syntax and semantics to receive correct results.
Incorrect Answers
A: JOIN ON keywords need to be used to build correct query.
C: This query will built Cartesian product because there is no join conditions in WHERE clause to
join tables.
E: NATURAL JOIN is a join between two where Oracle joins the tables according to the
column(s) in the two tables sharing the same name. It is required to add one more NATURAL
JOIN clause to join additional table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 98-118
Chapter 3: Advanced Data Selection in Oracle
Question: 95. (D)
Examine the data from the CLASS and INSTRUCTOR tables.
CLASS Table
CLASS_I
D
CLASS_NAME HOURS_CREDI
T
INSTRUCTOR_ID
1 Introduction to
Accounting
3 4
2 Computer Basics 3 1
3 Tax Accounting
Principles
3 4
4 American History 3 2
5 Basic Engineering 3
INSTRUCTOR Table
INSTRUCTOR_ID LAST_NAME FIRST_NAME
1 Chao Ling
2 Vanderbilt Herbert
3 Wigley Martha
4 Page Albert
You have been asked to produce a report of all instructors, including the classes taught by each
instructor. All instructors must be included on the report, even if they are not currently assigned to
teach classes. Which two SELECT statements could you use? (Choose two.)
A. SELECT i.last_name, i.first_name, c.class_name
FROM instructor i NATURAL JOIN class c
ON (i.instructor_id = c.instructor_id);
B. SELECT i.last_name, i.first_name, c.class_name
FROM instructor i, class c;
C. SELECT i.last_name, i.first_name, c.class_name
FROM class c LEFT OUTER JOIN instructor i
ON (i.instructor_id = c.instructor_id)
ORDER BY i.instructor_id;
D. SELECT i.last_name, i.first_name, c.class_name
FROM instructor i, class c
WHERE i.instructor_id = c.instructor_id (+)
ORDER BY i.instructor_id;
E. SELECT i.last_name, i.first_name, c.class_name
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 63 of 179
FROM instructor i LEFT OUTER JOIN class c
ON (i.instructor_id = c.instructor_id)
ORDER BY i.instructor_id;
F. SELECT i.last_name, i.first_name, c.class_name
FROM instructor i, class c
WHERE i.instructor_id (+) = c.instructor_id
ORDER BY i.instructor_id;
Answer: D & E
Explanation:
Two methods can be used using outer join to find the class with no instructor you can use a plus
sign (+) with the with the side that has information missing and LEFT OUTER JOIN is also used
to find the missing information.
Question: 96. (D)
Which two operators can be used in an outer join condition? (Choose two.)
A. =
B. OR
C. IN
D. AND
Answer: A & D
Explanation:
Outer Join can be used to also see rows that do not meet the join condition.
For an outer join you can use the equality (=) operator with AND operator in the join condition.
Question: 97. (D)
Examine the data from the CLASS and INSTRUCTOR tables.
CLASS Table
CLASS_ID CLASS_NAME HOURS_CREDIT INSTRUCTOR_ID
1 Introduction to
Accounting
3 4
2 Computer Basics 3 1
3 Tax Accounting
Principles
3 4
4 American History 3 2
5 Basic Engineering
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 64 of 179
INSTRUCTOR Table
INSTRUCTOR_ID LAST_NAME FIRST_NAME
1 Chao Ling
2 Vanderbilt Herbert
3 Wigley Martha
4 Page Albert
You want to retrieve a list of all classes, including those with no instructor currently assigned.
Which SELECT statement should you use?
A. SELECT c.class_name, i.last_name || ', ' || i.first_name InstructorName
FROM instructor i, class c
WHERE i.instructor_id = c.instructor_id (+);
B. SELECT c.class_name, i.last_name || ', ' || i.first_name InstructorName
FROM instructor I JOIN class c
WHERE i.instructor_id (+) = c.instructor_id;
C. SELECT c.class_name, i.last_name || ', ' || i.first_name InstructorName
FROM instructor i RIGHT OUTER JOIN class c
ON (i.instructor_id = c.instructor_id);
D. SELECT class_name, last_name || ', ' || first_name InstructorName
FROM instructor RIGHT OUTER JOIN class;
E. SELECT c.class_name, i.last_name || ', ' || i.first_name InstructorName
FROM instructor i RIGHT OUTER JOIN class c
USING (instructor_id);
Answer: C
Explanation:
Oracle 9i allows the use of one of two directives, left outer join and right outer join. To find all a list
of all classes that do not have any instructor assigned can be retrieved as
SELECT c.class_name, i.last_name || ', ' || i.first_name InstructorName
FROM instructor i RIGHT OUTER JOIN class c
ON (i.instructor_id = c.instructor_id);
Question: 98. (D)
To produce a meaningful result set without any cartesian products, what is the minimum number
of conditions that should appear in the WHERE clause of a four-table join?
A) 8
B) 2
C) 3
D) 4
E) 5
F) There is no such criteria
Answer: C
Explanation:
When we join different tables in where clause so n-1 conditions are used and n is the number of
tables which we are join.
Incorrect answers
A) This is not a valid value 8.
B) 2.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 65 of 179
D) 4.
E) 5.
F) There is no such criteria.
Reference:
OCP Introduction to Oracle 9i: SQL Displaying Data From Multiple Tables.
Question: 99.(E)
Examine the data in the EMPLOYEES table:
LAST_NAME DEPARTMENT_ID SALARY
Getz 10 3000
Davis 20 1500
King 20 2200
Davis 30 5000

Which three subqueries work? (Choose three)
A. SELECT *
FROM employees
where salary > (SELECT MIN(salary)
FROM employees
GROUP BY department.id);
B. SELECT *
FROM employees
WHERE salary = (SELECT AVG(salary)
FROM employees
GROUP BY department_id);
C. SELECT distinct department_id
FROM employees
Where salary > ANY (SELECT AVG(salary)
FROM employees
GROUP BY department_id);
D. SELECT department_id
FROM employees
WHERE SALARY > ALL (SELECT AVG(salary)
FROM employees.
GROUP BY department_id);
E. SELECT last_name
FROM employees
Where salary > ANY (SELECT MAX(salary)
FROM employees
GROUP BY department_id);
F. SELECT department_id
FROM employees
WHERE salary > ALL (SELECT AVG(salary)
FROM employees
GROUP BY AVG(SALARY));
Answer: C, D & E
Explanation:
These answers show correct syntax, because they use ANY and ALL keywords for convert multirow
output of sub-query to one-row result.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 66 of 179
Incorrect Answers
A: This SELECT statement is incorrect because of multi-row return of sub-query: it will return
minimal salary for EACH department.
B: This SELECT statement is incorrect because of multi-row return of sub-query: it will return
average salary for EACH department.
F: This SELECT statement is incorrect because GROUP BY clause cannot contain functions, like
AVG(), MIN(), MAX() and so on.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 145-156
Chapter 4: Subqueries
Question: 100. (E)
Examine the data from the ORDERS and CUSTOMERS table.
ORDERS
ORD_ID ORD_DATE CUST_ID ORD_TOTAÖ
100 12-JAN-2000 15 10000
101 09-MAR-2000 40 8000
102 09-MAR-2000 35 12500
103 15-MAR-2000 15 12000
104 25-JUN-2000 15 6000
105 18-JUL-2000 20 5000
106 18-JUL-2000 35 7000
107 21-JUL-2000 20 6500
108 04-AUG-2000 10 8000
CUSTOMERS
CUST_ID CUST_NAME City
10 Smith LosAngeles
15 Bob San Francisco
20 Martin Chicago
25 Mary New York
30 Rina Chicago
35 Smith New York
40 Linda New York
Which SQL statement retrieves the order ID, customer ID, and order total for the orders that are
placed on the same day that Martin places his orders?
A. SELECT ord_id, cust_id, ord_total
FROM orders, customers
WHERE cust_name=’Mating’
AND ord_date IN (’18-JUL-2000’,’21-JUL-2000’);
B. SELECT ord_id, cust_id, ord_total
FROM orders
Where ord_date IN (SELECT ord_date
FROM orders
WHERE cust_id = (SELECT cust_id
FROM customers
WHERE cust_name =
‘Martin’));
C. SELECT ord_id, cust_id, ord_total
FROM orders
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 67 of 179
Where ord_date IN (SELECT ord_date
FROM orders, customers
Where cust_name = ‘Martin’);
D. SELECT ord_id, cust_id, ord_total
FROM orders
WHERE cust_id IN (SELECT cust_id
FROM customers
WHERE cust name = ‘Martin’);.
Answer: B
Explanation:
This query will return the order ID, customer ID, and order total for the orders that are placed on
the same day that Martin places his orders.
Incorrect Answers
A: This query returns only Martin’s orders for July 18, 2000 and July 21, 2002, not orders of
others that were placed on the same day that Martin placed his orders.
C: This query uses incorrect sub-query to extract dates when Martin placed his orders.
D: This query will return only Martin’s orders.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 145-156
Chapter 4: Subqueries
Question: 101. (E)
Examine the data from the ORDERS and CUSTOMERS tables.
ORDERS
ORD_ID ORD_DATE CUST_ID ORD_TOTAÖ
100 12-JAN-2000 15 10000
101 09-MAR-2000 40 8000
102 09-MAR-2000 35 12500
103 15-MAR-2000 15 12000.
104 25-JUN-2000 15 6000
105 18-JUL-2000 20 5000
106 18-JUL-2000 35 7000
107 21-JUL-2000 20 6500
109 04-AUG-2000 10 8000
CUSTOMERS
CUST_ID CUST_NAME CITY
10 Smith Los Angeles
15 Bob San Francisco
20 Martin Chicago
25 Mary New York
30 Rina Chicago
35 Smith New York
40 Lind New York
Evaluate the SQL statement:
SELECT *
FROM orders
WHERE cust_id = (SELECT cust_id
FROM customers
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 68 of 179
WHERE cust_name = 'Smith');
What is the result when the query is executed?
A.
ORD_ID ORD_DATE CUST_ID ORD_TOTAL
102 09-MAR-2000 35 12500
106 18-JUL-2000 35 7000
108 04-AUG-2000 10 8000
B.
ORD_ID ORD_DATE CUST_ID ORD_TOTAL
102 09-MAR-2000 35 12500
106 18-JUL-2000 35 7000
C.
ORD_ID ORD_DATE CUST_ID ORD_TOTAL
108 04-AUG-2000 10 8000
D. The query fails because the subquery returns more than one row.
E. The query fails because the outer query and the inner query are using different tables.
Answer: D
Explanation:
The query fails because the sub-query returns more than one row: it is possible situation when
there are some customers with name Smith.
Incorrect Answers
A: The query fails because the sub-query returns more than one row
B: The query fails because the sub-query returns more than one row
C: The query fails because the sub-query returns more than one row
E: The query fails because the sub-query returns more than one row, not because the outer
query and the inner query are using different tables.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 150-165
Chapter 4: Subqueries
Question: 102. (E)
Evaluate this SQL statement:
SELECT product_id, product_name, price
FROM product
WHERE supplier_id IN
(SELECT supplier_id
FROM product
WHERE price > 120
OR qty_in_stock > 100);
Which values will be displayed?
A. The PRODUCT_ID, PRODUCT_NAME, and PRICE of products that are priced greater than
$120.00 and have a QTY_IN_STOCK value greater than 100.
B. The PRODUCT_ID , PRODUCT_NAME, and PRICE of products that are priced greater than
$120.00 or that have a QTY_IN_STOCK value greater than 100.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 69 of 179
C. The PRODUCT_ID, PRODUCT_NAME, and PRICE of products that are priced greater than
$120.00 or that have a QTY_IN_STOCK value greater than 100 and have a supplier.
D. The PRODUCT_ID, PRODUCT_NAME, and PRICE of products supplied by a supplier with
products that are priced greater than $120.00 or with products that have a QTY_IN_STOCK
value greater than 100.
Answer: D
Explanation:
Ans D is correct for the above written query as only the product_id, product_name and price of all
those product those have price greater than $120 or have QTY_IN_STOCK is greater than 100.
this has been done by using subquery you can also get same result by omitting subquery and use
the conditions directly in the WHERE clause of the main query.
Question: 103. (E)
Which statement regarding subqueries is true?
A. A subquery CANNOT reference a table that is not included in the outer query's FROM clause.
B. Subqueries can be nested up to 5 levels.
C. A subquery must be placed on the right side of the comparison operator.
D. Subqueries can return multiple columns.
Answer: D
Explanation:
Subquery is a SELECT statement which is embedded in a clause of another SELECT statement
retrieve data base on an unknown condition. You can build a powerful statement out of simple
one by using subqueries. A single row subqueries can return only one row but many columns
while a multiple row subqueries can return multiple rows and multiple columns
Question: 104. (E)
Evaluate this SELECT statement:
SELECT employee_id, name
FROM employee
WHERE employee_id NOT IN (SELECT employee_id
FROM employee
WHERE department_id = 30
AND job = 'CLERK');
What would happen if the inner query returned a NULL value?
A. No rows would be selected from the EMPLOYEE table.
B. All the EMPLOYEE_ID and NAME values in the EMPLOYEE table would be displayed.
C. Only the rows with EMPLOYEE_ID values equal to NULL would be included in the results.
D. A syntax error would be returned.
Answer: A
Explanation:
If a subquery return a NULL value to the main query then the no rows would be select from the
employee table.
Question: 105. (E)
Examine the data from the DONATION table (PLEDGE_ID is the primary key).
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 70 of 179
PLEDGE_I
N
DONOR_I
D
PLEDGE_D
T
AMOUNT_PLED
GED
AMOUNT_P
AID
PAYMENT_DT
1 1 10-SEP-
2001
1000 1000 02-OCT-2001
2 1 22-EFB-
2002
1000
3 2 08-OCT-
2001
10 10 28-OCT-2001
4 2 10-DEC-
2001
50
5 3 02-NOV-
2001
10000 9000 28-DEC-2001
6 3 05-JAN-
2002
1000 1000 31-JAN-2002
7 4 09-NOV-
2001
2100 2100 15-DEC-2001
8 5 09-DEC-
2001
110 110 29-DEC-2001
This statement fails when executed:
SELECT amount_pledged, amount_paid
FROM donation
WHERE donor_id =
(SELECT donor_id
FROM donation
WHERE amount_pledged = 1000.00
OR pledge_dt = '05-JAN-2002');
Which two changes could correct the problem? (Choose two.)
A. Remove the subquery WHERE clause.
B. Change the outer query WHERE clause to 'WHERE donor_id IN'.
C. Change the outer query WHERE clause to 'WHERE donor_id LIKE'.
D. Remove the single quotes around the date value in the inner query WHERE clause.
E. Change the subquery WHERE clause to 'WHERE amount_pledged = 1000.00 AND
pledge_dt = '05-JAN-2002' '.
F. Include the DONOR_ID column in the select list of the outer query.
Answer: B & E
Explanation:
When using multiple row subquery then you must use multi row operator with the subquery as in
the above written statement equality operator (=) use with the WHERE clause should be replaced
with IN operator to execute the query successfully. For the above query you can also remove the
subquery and make the condtion in the where clause of main query which is used in the
subquery.
Question: 106. (E)
A subquery can be used to _________.
A. Create groups of data.
B. Sort data in a specific order
C. Convert data to a different format
D. Retrieve data based on an unknown condition
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 71 of 179
Answer: D
Explanation:
A sub-query can be used to retrieve data based on an unknown condition
Incorrect Answers
A: A sub-query cannot be used to create groups of data, GROUP BY clause is used for that.
B: A sub-query cannot be used to sort data in a specific order, ORDER BY clause is used for
that.
C: A sub-query cannot convert data to a different format.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 150-165
Chapter 4: Subqueries
Question: 107. (E)
Which three statements about subqueries are true? (Choose three)
A. A single row subquery can retrieve only one column and one row.
B. A single row subquery can retrieve only one row but many columns.
C. A multiple row subquery can retrieve multiple rows and multiple columns.
D. A multiple row subquery can be compared by using the “>” operator.
E. A single row subquery can use the IN operator.
F. A multiple row subquery can use the “=” operator.
Answer: B, C, E
Question: 108. (E)
You define a multiple-row subquery in the WHERE clause of an SQL query with a comparison
operator "=".
What happens when the main query is executed?
A. The main query executes with the first value returned by the subquery.
B. The main query executes with the last value returned by the subquery.
C. The main query executes with all the values returned by the subquery.
D. The main query fails because the multiple-row subquery cannot be used with the comparison
operator
E. You cannot define a multiple-row subquery in the WHERE clause of a SQL query.
Answer: D
Explanation:
The main query fails because the multiple-row sub-query cannot be used with the comparison
operator. Only single-row query can use comparison operators, like =, <, >, <=, >, and <>.
Incorrect Answers
A: The main query fails because the multiple-row sub-query cannot be used with the comparison
operator.
B: The main query fails because the multiple-row sub-query cannot be used with the comparison
operator.
C: The main query fails because the multiple-row sub-query cannot be used with the comparison
operator.
E: You can define a multiple-row sub-query in the WHERE clause of a SQL query, but error will
be generated by different reason.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 72 of 179
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 150-165
Chapter 4: Subqueries
Question: 109. (E)
Which operator can be used with a multiple-row subquery?
A. =
B. LIKE
C. BETWEEN
D. NOT IN
E. IS
F. <>
Answer: D
Explanation:
Only NOT IN operator can be used with a multi-row sub-query. All others may be used with
single-row sub-query only.
Incorrect Answers
A: When sub-queries are linked to the parent by equality comparisons, the parent query expects
only one row of data from the sub-query, so “=” operator cannot be used with a multiple-row
sub-query.
B: Operator LIKE will work only with single-row sub-queries.
C: Operator BETWEEN will not work with a multi-row sub-queries.
E: Operator LIKE is used only for single-row sub-queries.
F: When sub-queries are linked to the parent by equality comparisons, the parent query expects
only one row of data from the sub-query, so “<>” operator cannot be used with a multiple-row
sub-query.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 150-165
Chapter 4: Subqueries
Question: 110. (E)
Which two statements about subqueries are true? (Choose two.)
A. A single row subquery can retrieve data from only one table.
B. A SQL query statement cannot display data from table B that is referred to in its
subquery, unless table B is included in the main query's FROM clause.
C. A SQL query statement can display data from table B that is referred to in its subquery,
without including table B in its own FROM clause.
D A single row subquery can retrieve data from more than one table.
E. A single row subquery cannot be used in a condition where the LIKE operator is used for
comparison.
F. A multiple-row subquery cannot be used in a condition where the LIKE operator is used for
comparison.
Answer: B & D
Explanation:
A SQL query statement cannot display data from table B that is referred to in its sub-query,
funless table B is included in the main query's FROM clause. And a single row sub-query can
retrieve data from more than one table.
Incorrect Answers
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 73 of 179
A: A single row sub-query can retrieve data from more than one table.
C: A SQL query statement cannot display data from table B that is referred to in its subquery,
unless table B is included in the main query's FROM clause.
E: A single row sub-query can be used in a condition where the LIKE operator is used for
comparison.
F: A multiple-row sub-query can be used in a condition where the LIKE operator is used for
comparison.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 144-150
Chapter 4: Subqueries
Question: 111. (E)
Examine the data from the EMP table:
EMP_ID DEPT_ID COMMISSION
1 10 500
2 20 1000
3 10
4 10 600
5 30 800
6 30 200
7 10
8 20 300
The COMMISSION column shows the monthly commission earned by the employee.
Which three tasks would require subqueries or joins in order to perform in a single step? (Choose
three)
A. Deleting the records of employees who do not earn commission.
B. Increasing the commission of employee 3 by the average commission earned in department
20.
C. Finding the cumber of employees who do NOT earn commission and are working for
department 20.
D. Inserting into the table a new employee 10 who works for department 20 and earns a
commission that is equal to the commission earned by employee 3.
E. Creating a table called COMMISSION that has the same structure and data as the columns
EMP_ID and COMMISSIONS of the EMP table.
F. Decreasing the commission by 150 for the employees who are working in department 30 and
earning a commission of more then 800.
Answer: B, D & E
Explanation:
Increasing the commission of employee 3 by the average commission earned in department 20
will require sub-queries or joins in order to perform in a single step. Inserting into the table a new
employee 10 who works for department 20 and earns a commission that is equal to the
commission earned by employee 3 is correct answer also. To create a table that has the same
structure as subset of columns from another table it’s required to use a subquery in order to
perform in a single step.
Incorrect Answers
A: This query can be done without using sub-queries or joins in order to perform in a single step.
C: It is not required to use sub-queries or joins to create SQL statement for that query.
F: This query can be done without using sub-queries or joins in order to perform in a single step:
only two conditions in the WHERE clause should be specified.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 74 of 179
Question: 112. (E)
Which substitution variable would you use if you want to reuse the variable without prompting the
user each time?
A. &
B. ACCEPT
C. PROMPT
D. &&
Answer: D
Explanation:
To reuse the variable without prompting the user each time you can use && substitution variable.
Incorrect Answers
A: This substitution variable will prompt the user each time.
B: ACCEPT is command, not substitution variable. It used to define more accurate or specific
prompt or when you want more output to display as the values are defined.
C: PROMPT is part of the ACCEPT command, it is not a variable.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 165-173
Chapter 4: Subqueries
Question: 113. (E)
Which SQL statement accepts user input for the columns to be displayed, the table name, and
WHERE condition?
A. SELECT &1, "&2"
FROM &3
WHERE last_name = '&4';
B. SELECT &1, '&2'
FROM &3
WHERE '&last_name = '&4' ';
C. SELECT &1, &2
FROM &3
WHERE last_name = '&4';
D. SELECT &1, '&2'
FROM EMP
WHERE last_name = '&4';
Answer: C
Explanation :
In a WHERE clause, date and characters values must be enclosed within single quotation marks.
Sample of the correct syntax
SELECT EMPLOYEE_ID, &COLUMN_NAME
FROM EMPLOYEES
Incorrect Answers :
A. Incorrect use of " symbol
B. Incorrect use of ' symbol
D. No input for table name as EMP has been use in the statement.
Reference:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 75 of 179
Introduction to Oracle9i : SQL, Oracle University Student Guide, Producing Readable Output with
iSQL*PLUS, p. 7-8
Question: 114. (E)
Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2 (25)
LAST_NAME VARCHAR2 (25)
HIRE_DATE DATE
NEW EMPLOYEES:
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2 (60)
Which DELETE statement is valid?
A. DELETE FROM employees
WHERE employee_id = (SELECT employee_id
FROM employees);
B. DELETE * FROM employees
WHERE employee_id = (SELECT employee_id
FROM new_employees);
C. DELETE FROM employees
WHERE employee_id IN (SELECT employee_id
FROM new_employees
WHERE name = 'Carrey');
D. DELETE * FROM employees
WHERE employee_id IN (SELECT employee_id
FROM new_employees
WHERE last_name = 'Carrey');
Answer: C
Explanation :
The correct syntax for DELETE statement
DELETE [ FROM ] table
[ WHERE condition ];
Incorrect Answers :
A. '=' is use in the statement and subquery will return more than one row.
Error Ora-01427 : single-row subquery returns more than one row.
B. Incorrect DELETE statement
D. Incorrect DELETE statement
Reference:
Introduction to Oracle9i : SQL, Oracle University Student Guide, Manipulating Data, p. 8-19
Question: 115. (E)
Evaluate this SQL*Plus command:
COLUMN teacher_name HEADING 'Teacher' FORMAT A25
Which two tasks will this command accomplish? (Choose two.)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 76 of 179
A. It will set the TEACHER_NAME column heading to 'Teacher'.
B. It will center the column heading of the TEACHER_NAME column.
C. It will limit the TEACHER_NAME column heading to 25 characters.
D. It will display the current settings for the TEACHER_NAME column.
E. It will set the display width of the TEACHER_NAME column to 25.
Answer: A & E
Explanation:
COLUMN command is used to change the display format of the column result value. As for the
above statement the heading for TEACHER_NAME will become ‘Teacher’ and the width for the
this column will be 25.
Question: 116. (E)
The STUDENT table contains these columns:
ID NUMBER(9) PK
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
STU_TYPE VARCHAR2(1)
ENROLL_DATE DATE
Evaluate this iSQL*Plus script:
SELECT id, last_name, first_name, enroll_date
FROM student
WHERE stu_type = '&stype'
AND enroll_date between &&bdate and &&edate
/
What happens when this script is run a second time in the same session?
A. The user is prompted for all three substitution variables.
B. An error occurs because the STYPE substitution variable is NOT correctly specified.
C. The values of BDATE and EDATE from the previous execution are used.
D. An error occurs because the BDATE and EDATE substitution variables are NOT correctly
specified.
Answer: C
Explanation:
Use the double ampersand (&&) substitution variable if you want to reuse the variable value with
out prompting the user each time. The user will see the prompt for the value only once and the
values will be used from the previous execution. In the above statement the values of BDATE and
EDATE from the previous execution are used.
Question: 117. (E)
Evaluate this SELECT statement:
SELECT order_num, &order_date
FROM &&ordertbl
WHERE order_date = '&order_date';
Which statement regarding the execution of this statement is true?
A. The user will be prompted for all values in the select list each time the statement is executed
in a session.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 77 of 179
B. The user will be prompted for the table name each time the statement is executed in a
session.
C. An error will occur when executing this statement because substitution variables are NOT
allowed in a WHERE clause.
D. The user will be prompted for the table name only the first time the statement is executed in a
session.
E. An error will occur when executing this statement because substitution variables must be
unique within a SELECT statement.
Answer: D
Explanation:
When double ampersand (&&) substitution variable is used then user will only be prompted for
once and the same value will be used again it will not ask you for a value for substitution variable
again.
Question: 118. (E)
The INVENTORY table contains these columns:
ID_NUMBER NUMBER PK
DESCRIPTION VARCHAR2(30)
SUPPLIER_ID NUMBER
You want to create a query that for each session allows the user to input a value for
DESCRIPTION each time the query runs. While the DESCRIPTION column is stored in upper
case, you want the query to retrieve matching values regardless of the case used when inputting
the substitution variable value.
Which SELECT statement should you use?
A. SELECT id_number, supplier_id
FROM inventory
WHERE description = UPPER(&description);
B. SELECT id_number, supplier_id
FROM inventory
WHERE LOWER(description) = LOWER('&description');
C. SELECT id_number, supplier_id
FROM inventory
WHERE LOWER(description) = '&description';
D. SELECT id_number, supplier_id
FROM inventory
WHERE description = UPPER('&&description');
Answer: B
Explanation:
To retrieve the matching values regardless of the case used when inputting the substitution
variable value use the function LOWER which will change the case of stored value and
substitution variable value to compare them.
Question: 119. (E)
In which clauses of a SELECT statement can substitution variables be used?
A. the SELECT, WHERE, GROUP BY, and ORDER BY clauses, but NOT the FROM clause
B. the SELECT, FROM, WHERE, and GROUP BY clauses, but NOT the ORDER BY clause
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 78 of 179
C. the SELECT and FROM clauses, but NOT the WHERE clause
D. the SELECT, FROM, and WHERE clauses only
E. the SELECT, FROM, WHERE, GROUP BY, ORDER BY, and HAVING clauses
Answer: E
Explanation:
Substitution variable can be used in the SELECT, FROM, WHERE, GROUP BY, ORDER BY and
HAVING clause.
Question: 120. (E)
What is the default character for specifying substitution variable in select statement?
A. Ampersand.
B. Ellipses.
C. Quotations marks.
D. Asterik
Answer: A
Explanation:
The ampersand (&) character is used by default to define runtime variable in SQL*Plus.
Question: 121.(F)
Which four are correct guidelines for naming database tables? (Choose four)
A. Must begin with either a number or a letter.
B. Must be 1-30 characters long.
C. Should not be an Oracle Server reserved word.
D. Must contain only A-Z, a-z, 0-+, _, *, and #.
E. Must contain only A-Z, a-z, 0-9, _, $, and #.
F. Must begin with a letter.
Answer: B, C, E, F
Explanation:
Oracle database object must begin with a letter and can usually be between 1 and 30 characters
long, except for databases (which have a maximum of eight characters) and database links (with
a maximum of 128 characters). Name cannot be an Oracle Server reserved word. Name must
contain only A-Z, a-z, 0-9, _, $, and #.
Incorrect Answers
A: Database tables may not begin with number.
D: It cannot contain symbols “+” or “*”.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 208-211
Chapter 5: Creating Oracle Database Objects
Question: 122. (F)
Examine the structure of the EMPLOYEES table:
Column name Data type Remarks
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCNAR2(30)
FIRST_NAME VARCNAR2(30)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 79 of 179
JOB_ID NUMBER
SAL NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER
You need to create an index called NAME_IDX on the first name and last name fields of the
EMPLOYEES table. Which SQL statement would you use to perform this task?
A. CREATE INDEX NAME_IDX (first_name, last_name);
B. CREATE INDEX NAME_IDX (first_name AND last_name);
C. CREATE INDEX NAME_IDX
ON (first_name, last_name);
D. CREATE INDEX NAME_IDX
ON employees (first_name AND last_name);
E. CREATE INDEX NAME_IDX
ON employees(first_name, last_name);
F. CREATE INDEX NAME_IDX
FOR employees(first_name, last_name);
Answer: E
Explanation:
Answer E provides correct syntax to create index: CREATE INDEX index_name ON
table_name(list of columns).
Incorrect Answers
A: You need to use keyword ON also to create index.
B: You cannot use keyword AND to build a list of columns for index. Also this statement is
missing the table name on which the index is creating.
C: This statement is missing the table name on which the index is creating.
D: You cannot use keyword AND to build a list of columns for index.
F: You cannot use keyword FOR to create an index.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 322-331
Chapter 7: Creating Other Database Objects in Oracle
Question: 123. (F)
Which three are DATETIME data types that can be used when specifying column definitions?
(Choose three.)
A. TIMESTAMP
B. INTERVAL MONTH TO DAY
C. INTERVAL DAY TO SECOND
D. INTERVAL YEAR TO MONTH
E. TIMESTAMP WITH DATABASE TIMEZONE
Answer: A, C & D
Explanation:
TIMESTAMP, INTERVAL DAY TO SECOND and INTERVAL YEAR TO MONTH can be used to
specify column definition.
Incorrect Answers
B: The INTERVAL MONTH TO DAY data type cannot be used when specifying column
definitions there are only INTERVAL DAY TO SECOND and INTERVAL YEAR TO MONTH
data types.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 80 of 179
E: The TIMESTAMP WITH DATABASE TIMEZONE data type cannot be used when specifying
column definitions, because there are only TIMESTAMP WITH TIME ZONE and TIMESTAMP
WITH LOCAL TIME ZONE data types.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 215-217
Chapter 5: Creating Oracle Database Objects
Question: 124. (F)
What does the TRUNCATE statement do?
A. Removes the table
B. Removes all rows from a table
C. Shortens the table to 10 rows
D. Removes all columns from a table
E. Removes foreign keys from a table
Answer: B
Explanation:
Command TRUNCATE is used to remove all row data from the table, while leaving the definition
of the table intact, including the definition of constraints and any associated database objects as
indexes, constraints, and triggers on the table.
Incorrect Answers
A: Command TRUNCATE does not remove the table. DROP TABLE command does that.
C: There is no command in Oracle to shortens the table to 10 rows: but you can do this with
queries.
D: This command does not remove all columns from a table.
E: This command does not remove all foreign keys from a table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 225
Chapter 5: Creating Oracle Database Objects
Question: 125. (F)
Which statement about a table is true?
A. A table can have up to 10,000 columns.
B. The size of a table does NOT need to be specified.
C. A table CANNOT be created while users are using the database.
D. The structure of a table CANNOT be modified while the table is online.
Answer: B
Explanation:
When creating a table there is no need to specify the table size. Table will get the default settings
for it. Tables can be created when the users are using the database and table structure can be
modified online.
Question: 126. (F)
The ACCOUNT table contains these columns:
ACCOUNT_ID NUMBER(12)
FINANCE_CHARGE NUMBER(7,2)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 81 of 179
PREV_BALANCE NUMBER(7,2)
PAYMENTS NUMBER(7,2)
NEW_PURCHASES NUMBER(7,2)
You created the ACCOUNT_ID_SEQ sequence to generate sequential values for the
ACCOUNT_ID column.
You issue this statement:
ALTER TABLE account
MODIFY (finance_charge NUMBER(8,2));
Which statement about the ACCOUNT_ID_SEQ sequence is true?
A. The sequence is dropped.
B. The precision of the sequence is changed.
C. The sequence is reverted to its minimum value.
D. The sequence is unchanged.
Answer: D
Explanation:
When the sequence is created then the ALTER TABLE command have no effect on the state of
sequence and the sequence will remain unchanged.
Question: 127. (F)
Examine the structure of the EMPLOYEE table.
EMPLOYEE Table
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_LNAME VARCHAR2 (25)
EMP_FNAME VARCHAR2 (25)
DEPT_ID NUMBER Foreign key to DEPT_ID column of the DEPARTMENT table
JOB_ID NUMBER Foreign key to JOB_ID column of the JOB table
MGR_ID NUMBER References EMPLOYEE_ID column
SALARY NUMBER (9,2)
HIRE_DATE DATE
DPB DATE
Which statement should you use to increase the EMP_LNAME column length to 25 if the column
currently contains 3000 records?
A. You CANNOT increase the width of the EMP_LNAME column.
B. ALTER TABLE employee
MODIFY emp_lname VARCHAR2(25);
C. ALTER TABLE employee
RENAME emp_lname VARCHAR2(25);
D. ALTER employee TABLE
MODIFY COLUMN emp_lname VARCHAR2(25);
E. ALTER employee TABLE
MODIFY COLUMN (emp_lname VARCHAR2(25));
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 82 of 179
Answer: B
Explanation:
You can change the size of the column but this change will have effect only on the future inserts.
To change the size of the column datatype use the command
ALTER TABLE employee
MODIFY emp_lname VARCHAR2(25);
Question: 128. (F)
Examine the structure of the PO_DETAIL table.
PO_DETAIL Table
PO-NUM PO_LINE_IN PRODUCT_ID QUANTITY UNIT_PRICE
10052 1 1 100 10.30
10052 2 2 100 10.00
10054 1 1 50 72.00
10054 2 2 10 10.00
10054 3 3 10 10.00
Which statement will permanently remove all the data in, the indexes on, and the structure of the
PO_DETAIL table?
A. DELETE TABLE po_detail;
B. TRUNCATE TABLE po_detail;
C. ALTER TABLE po_detail
SET UNUSED (po_num, po_line_id, product_id, quantity, unit_price);
D. DROP TABLE po_detail;
Answer: D
Explanation:
DROP TABLE command will completely remove the table structure, its all data all the indexes on
the table and constraints will also be removed. Only the view and synonym for the table will
remain but they are invalid.
Question: 129.
Examine the structure of the EMPLOYEE table.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 83 of 179
EMPLOYEE Table
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_LNAME VARCHAR2 (25)
EMP_FNAME VARCHAR2 (25)
DEPT_ID NUMBER Foreign key to DEPT_ID column of the DEPARTMENT
table
JOB_ID NUMBER Foreign key to JOB_ID column of the JOB table
MGR_ID NUMBER References EMPLOYEE_ID column
SALARY NUMBER (9,2)
HIRE_DATE DATE
DPB DATE
The MGR_ID column currently contains employee identification numbers, and you need to allow
users to include text characters in the identification values. Which statement should you use to
implement this?
A. ALTER employee
MODIFY (mgr_id VARCHAR2(15));
B. ALTER TABLE employee
MODIFY (mgr_id VARCHAR2(15));
C. ALTER employee TABLE
MODIFY COLUMN (mgr_id VARCHAR2(15));
D. ALTER TABLE employee
REPLACE (mgr_id VARCHAR2(15));
E. You CANNOT modify the data type of the MGR_ID column.
Answer: E
Explanation:
Using MODIFY command you can change the size of the column but you cannot change the
datatype of a column.
Question: 130. (F)
Which CREATE TABLE statements will fail? (Choose all that apply.)
A. CREATE TABLE time1 (time1 NUMBER(9));
B. CREATE TABLE date (time_id NUMBER(9));
C. CREATE TABLE time (time_id NUMBER(9));
D. CREATE TABLE time* (time_id NUMBER(9));
E. CREATE TABLE $time (time_id NUMBER(9));
F. CREATE TABLE datetime (time_id NUMBER(9));
Answer: B, D & E
Explanation:
When creating table the name of table must start with character. It can use the A-Z, a-z, 0-9, _, $,
# for the table name but name must start with character. Also the oracle database reserved
cannot be used in the table name.
Question: 131. (F)
Evaluate this statement:
SELECT *
FROM greg.customer;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 84 of 179
If as user Chan you execute this statement successfully, which statement must be true?
A. The CUSTOMER table exists in user Greg's schema.
B. The CUSTOMER table was created in the DBA schema.
C. The CUSTOMER table was created in the public schema.
D. The CUSTOMER table is accessible to all users.
Answer: A
Explanation:
For the above statement to execute successful you must have access privileges on the table and
the table must exist in the greg user schema.
Question: 132. (F)
Logged on as user Ann, you issue these SQL statements:
CREATE TABLE customer (
customer_id NUMBER,
company_id VARCHAR2(30),
contact_name VARCHAR2(30),
contact_title VARCHAR2(20),
address VARCHAR2(30),
city VARCHAR2(25),
region VARCHAR2(10),
postal_code VARCHAR2(20),
country_id NUMBER,
phone VARCHAR2(20),
fax VARCHAR2(20),
credit_limit NUMBER (7,2));
CREATE PUBLIC SYNONYM cust
FOR customer;
GRANT SELECT ON customer TO chan;
Which SELECT statements could user Chan issue to access the CUSTOMER table? (Choose all
that apply.)
A. SELECT *
FROM ann.customer;
B. SELECT customer_id
FROM customer;
C. SELECT customer_name, phone
FROM cust;
D. SELECT *
FROM ann.cust;
E. SELECT COUNT(city)
FROM chan.cust;
Answer: A & C
Explanation:
Simplify access to the objects by creating a synonym which is another name for an object.
For the above statement user Chan can access ann customer table using synonym as
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 85 of 179
SELECT customer_name, phone
FROM cust;
As the user ann grant SELECT privileges to the user chan so chan will also access the table
using following command
SELECT customer_name, phone
FROM cust;
Question: 133. (F)
Evaluate this CREATE TABLE statement:
CREATE TABLE curr_order (
id NUMBER,
customer_id NUMBER,
emp_id NUMBER,
order_dt TIMESTAMP WITH LOCAL TIME ZONE,
order_amt NUMBER(7,2),
ship_method VARCHAR2(5));
Which statement about the ORDER_DT column is true?
A. Data will be normalized to the database time zone.
B. Data will include a time zone displacement in its value.
C. Data stored in the column will be returned in the server's local time zone.
D. Data will be stored using a fractional seconds precision of 3.
Answer: A
Explanation:
TIMESTAMP WITH LOCAL TIME ZONE is another variant of TIMESTAMP that includes a time
zone displacement in its value. It differs from TIMESTAMP WITH TIME ZONE in that data stored
in the database is normalized to the database time zone, and the time zone displacement is not
stored as part of the column data. When users retrieve the data, Oracle returns it in the users'
local ession time zone.
Question: 134. (F)
Examine the structure of the PRODUCT table.
PRODUCT_ID NUMBER NOT NULL, Primary Key
PRODUCT_NAME VARCHAR2 (25)
SUPPLIER_ID NUMBER Foreign key to SUPPLIER_ID of the SUPPLIER table
LIST_PRICE NUMBER (7,2)
COST NUMBER (7,2)
QTY_IN_STOCK NUMBER
QTY_ON_ORDER NUMBER
REORDER_LEVEL NUMBER
REORDER_QTY NUMBER
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 86 of 179
You need to reduce the LIST_PRICE column precision to 6 with a scale of 2 and ensure that
when inserting a row into the PRODUCT table without a value for the LIST_PRICE column, a
price of $5.00 will automatically be inserted. The PRODUCT table currently contains no records.
Which statement should you use?
A. ALTER TABLE product
ADD OR REPLACE (list_price NUMBER(8,2) DEFAULT 5);
B. ALTER TABLE product
MODIFY (list_price NUMBER(6,2) DEFAULT 5);
C. ALTER TABLE product
MODIFY COLUMN (list_price NUMBER(6,2) DEFAULT '$5.00');
D. ALTER TABLE product
MODIFY (list_price NUMBER(8,2) DEFAULT 5)
REPLACE COLUMN (list_price NUMBER(6,2);
E. You CANNOT reduce the size of the LIST_PRICE column.
Answer: B
Explanation:
You can reduce the precision of column only if the column do not have any record in it. To do
change the size and also set a default value for the column use the command as.
ALTER TABLE product
MODIFY (list_price NUMBER(6,2) DEFAULT 5);
Question: 135. (F)
Which statements about data types are true? (Choose all that apply.)
A. The TIMESTAMP data type is an extension of the VARCHAR2 data type.
B. The BLOB data type stores character data up to four gigabytes.
C. The VARCHAR2 data type requires that a minimum size be specified when defining a column
of this type.
D. The CHAR datatype should be used for fixed-length character data.
E. The INTERVAL YEAR TO MONTH data type allows time to be stored as an interval of years
and months.
Answer: D & E
Explanation:
The CHAR datatype specifies a fixed-length character string. The default length for a CHAR
column is 1 byte and the maximum allowed is 2000 bytes.
Question: 136. (F)
Which ALTER TABLE statement should you use to add a PRIMARY KEY constraint on the
MANUFACTURER_ID column of the INVENTORY table?
A. ALTER TABLE inventory
ADD CONSTRAINT manufacturer_id PRIMARY KEY;
B. ALTER TABLE inventory
ADD PRIMARY KEY (manufacturer_id);
C. ALTER TABLE inventory
MODIFY manufacturer_id CONSTRAINT PRIMARY KEY;
D. ALTER TABLE inventory
MODIFY CONSTRAINT PRIMARY KEY manufacturer_id;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 87 of 179
Answer: B
Explanation:
To add a primary key constraint in the table use the following command
ALTER TABLE inventory
ADD PRIMARY KEY (manufacturer_id);
Question: 137. (F)
The EMPLOYEES table has these columns:
LAST NAME VARCHAR2(35)
SALARY NUMBER(8,2)
HIRE_DATE DATE
Management wants to add a default value to the SALARY column. You plan to alter the table by
using this SQL statement:
ALTER TABLE EMPLOYEES
MODIFY (SALARY DEFAULT 5000);
What is true about your ALTER statement?
A. Column definitions cannot be altered to add DEFAULT values.
B. A change to the DEFAULT value affects only subsequent insertions to the table.
C. Column definitions cannot be altered at add DEFAULT values for columns with a NUMBER
data type.
D. All the rows that have a NULL value for the SALARY column will be updated with the value
5000.
Answer: B
Explanation:
A change to the DEFAULT value affects only subsequent insertions to the table. Existing rows will
not be affected.
Incorrect Answers
A: Column definitions can be altered to add DEFAULT values.
C: Column definitions can be altered to add DEFAULT values. It works for columns with a
NUMBER data type also.
D: A change to the DEFAULT value affects only subsequent insertions to the table. Existing rows
will not be affected.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 219-224
Chapter 5: Creating Oracle Database Objects
Question: 138. (F)
You need to change the definition of an existing table. The COMMERCIALS table needs its
DESCRIPTION column changed to hold varying length characters up to 2000 bytes. The column
can currently hold 1000 bytes per value. The table contains 20000 rows.
Which statement is valid?
A. ALTER TABLE commercials
MODIFY (description CHAR2(2000));
B. ALTER TABLE commercials
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 88 of 179
CHANGE (description CHAR2(2000));
C. ALTER TABLE commercials
CHANGE (description VARCHAR2(2000));
D. ALTER TABLE commercials
MODIFY (description VARCHAR2(2000));
E. You cannot increase the size of a column if the table has rows.
Answer: D
Incorrect Answers
A: There is no CHAR2 datatype in Oracle. Also 200 symbols is not enough to store up to
2000 bytes.
B: There is no CHAR2 datatype in Oracle. There is no ALTER TABLE table_name CHANGE
command in Oracle.
C: There is no ALTER TABLE table_name CHANGE command in Oracle.
E: You can increase the size of a column if the table has rows. It can be done with ALTER
TABLE table_name MODIFY column.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 219-224
Chapter 5: Creating Oracle Database Objects
Question: 139. (F)
Evaluate the SQL statement
DROP TABLE DEPT:
Which four statements are true of the SQL statement? (Choose four)
A. You cannot roll back this statement.
B. All pending transactions are committed.
C. Al views based on the DEPT table are deleted.
D. All indexes based on the DEPT table are dropped.
E. All data in the table is deleted, and the table structure is also deleted.
F. All data in the table is deleted, but the structure of the table is retained.
G. All synonyms based on the DEPT table are deleted.
Answer: A, B, D & E
Explanation:
You cannot roll back DROP TABLE statement. All pending transactions related on this table are
committed. If the table is dropped, Oracle automatically drops any index, trigger and constraint
associated with the table as well. All data in the table is deleted, and the table structure is also
deleted.
Incorrect Answers
C: All views based on the DEPT table become invalid, but they are not deleted.
F: All data in the table is deleted, and the table structure is also deleted. Command
TRUNCATE deletes all data in the table, but does not delete the structure of the table.
G: All synonyms based on the DEPT table are not deleted after dropping the table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 225
Chapter 5: Creating Oracle Database Objects
Question: 140. (F)
Which statement describes the ROWID data type?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 89 of 179
A. Binary data up to 4 gigabytes.
B. Character data up to 4 gigabytes.
C. Raw binary data of variable length up to 2 gigabytes.
D. Binary data stored in an external file, up to 4 gigabytes.
E. A hexadecimal string representing the unique address of a row in its table.
Answer: E
Explanation:
The ROWID datatype stores information related to the disk location of table rows. They also
uniquely identify the rows in your table. The ROWID datatype is stored as a hexadecimal string.
Incorrect Answers
A: It is not a binary data. The ROWID datatype is a hexadecimal string.
B: It is not a character data. The ROWID datatype is a hexadecimal string.
C: It is not a raw binary data. The ROWID datatype is a hexadecimal string.
D: It is not binary data stored in an external file. The ROWID datatype is a hexadecimal string.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 216
Chapter 5: Creating Oracle Database Objects
Question: 141. (F)
You just issued the following statement.
Alter table marketing
Drop column profit;
Which of the following choices identified when the column will actually be removed from
database.
A. Immediately following statement execution.
B. After the Alter table drop unused columns command is issued.
C. After the Alter table set unused column command is issued.
D. After the Alter table modify command is issued.
Answer: A
Explanation:
When drop column command is issued then column will be immediately drop.
Question: 142. (F)
Which of the following can be a valid column name?
A) Number
B) 1966_Invoices
C) Catch_#22
D) #Invoices
E) None of the above
Answer: C
Explanation
Column name must be start with an alphabet.But not the reserved word of the oracle
Incorrect answers
A) Number is the reserved word in oracle.So it is not the name of column.
B) Column name Not start with a numeric value so 1966_invoices is not a valid name.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 90 of 179
D) Not start with a special character so #Invoices is not valid.
E) option C is a valid so this option is not true.reference:
Reference:
Introduction to Oracle 9i: SQL - Creating and Managing Tables
Question: 143.(G)
You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The
table is currently empty.
Which statement accomplishes this task?
A. ALTER TABLE students
ADD PRIMARY KEY student_id;
B. ALTER TABLE students
ADD CONSTRAINT PRIMARY KEY (student_id);
C. ALTER TABLE students
ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
D. ALTER TABLE students
ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
E. ALTER TABLE students
MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
Answer: D
Explanation:
This statement provides correct syntax to add a primary key on the STUDENT_ID column of the
STUDENT table.
Incorrect Answers
A: This ALTER TABLE statement is missing CONSTRAINT keyword and the name of the
constraint.
B: This ALTER TABLE statement is missing the name of the constraint.
C: It’s incorrect syntax in the ALTER TABLE command: STUDENT_ID must be used with
brackets.
E: We need to add constraint, not to modify existing one. Usage of the MODIFY keyword is
incorrect in this case.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 239-240
Chapter 5: Creating Oracle Database Objects
Question: 144. (G)
Which SQL statement defines the FOREIGN KEY constraint on the DEPTNO column of the EMP
table?
A. CREATE TABLE EMP
(empno NUMBER(4),
ename VARCNAR2(35),
deptno NUMBER(7,2) NOT NULL
CONSTRAINT emp_deptno_fk FOREIGN KEY deptno
REFERENCES dept deptno);
B. CREATE TABLE EMP
(empno NUMBER(4),
ename VARCNAR2(35),
deptno NUMBER(7,2)
CONSTRAINT emp_deptno_fk REFERENCES dept (deptno));
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 91 of 179
C. CREATE TABLE EMP
(empno NUMBER(4)
ename VARCHAR2(35),
deptno NUMBER(7,2) NOT NULL,
CONSTRAINT emp_deptno_fk REFERENCES dept (deptno)
FOREIGN KEY (deptno));
D. CREATE TABLE EMP (empno NUMBER(4),
ename VARCNAR2(35),
deptno NUMBER(7,2) FOREIGN KEY
CONSTRAINT emp deptno fk REFERENCES dept (deptno));
Answer: B
Explanation:
This statement provides correct syntax to define the FOREIGN KEY constraint on the DEPTNO
column of the EMP table.
Incorrect Answers
A: There is incorrect syntax, because list of columns and column for the constraint need to be
surrounded with the brackets.
C: It is incorrect to use FOREIGN KEY keywords to define constraint on the table. It can be used
to add integrity constraint to existing table.
D: It is incorrect to use FOREIGN KEY keywords to define constraint on the table. It can be used
to add integrity constraint to existing table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 238-245
Chapter 5: Creating Oracle Database Objects
Question: 145. (G)
Which three statements correctly describe the functions and use of constraints? (Choose three.)
A. Constraints provide data independence.
B. Constraints make complex queries easy.
C. Constraints enforce rules at the view level.
D. Constraints enforce rules at the table level.
E. Constraints prevent the deletion of a table if there are dependencies.
F. Constraints prevent the deletion of an index if there are dependencies.
Answer: C, D & E
Explanation:
Constraints have functions to enforce rules at the view and table levels and to prevent the
deletion of data if dependencies exist between tables.
Incorrect Answers
A: Constraints are used to put dependencies on data.
B: Constrains are not used to make complex queries more easy.
F: Constraints does not prevent the deletion of an index if there are dependencies.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 227-248
Chapter 5: Creating Oracle Database Objects
Question: 146. (G)
Which two statements about NOT NULL constraints are true? (Choose two.)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 92 of 179
A. NOT NULL constraints can only be defined at the column level.
B. You CANNOT define a NOT NULL column if the column does NOT have a non-null value for
every row.
C. You CANNOT add a NOT NULL constraint to an existing column using the ALTER TABLE
statement.
D. You can modify the structure of a NOT NULL constraint using the ALTER TABLE statement.
E. A NOT NULL constraint is stored in the data dictionary as a UNIQUE constraint.
Answer: A & B
Explanation:
NOT NULL constraints cannot be define at table level they can be define at column level. To
define a NOT NULL constraint for a column the column must not have any null values in it.
Question: 147. (G)
The PO_DETAIL table contains these columns:
PO_NUM NUMBER NOT NULL, Primary Key
PO_LINE_ID NUMBER NOT NULL, Primary Key
PRODUCT_ID NUMBER Foreign Key to PRODUCT_ID column of the PRODUCT table
QUANTITY NUMBER
UNIT_PRICE NUMBER(5,2)
Evaluate this statement:
ALTER TABLE po_detail
ENABLE CONSTRAINT po_num_pk;
For which task would you issue this statement?
A. to drop and recreate the PRIMARY KEY constraint on the PO_NUM column
B. to activate the previously disabled constraint on the PO_NUM column while creating a
PRIMARY KEY index
C. to create a new PRIMARY KEY constraint on the PO_NUM column
D. to enable any previously disabled FOREIGN KEY constraints that are dependent on the
PO_NUM column
Answer: B
Explanation:
To activate the previously disable constraints you can use the ENABLE clause in the ALTER
TABLE command.
ALTER TABLE po_detail
ENABLE CONSTRAINT po_num_pk;
Question: 148. (G)
Which two statements about constraints are true? (Choose two.)
A. Constraints only enforce rules at the table level.
B. Constraints prevent a table with dependencies from being deleted.
C. Constraints can be created at the same time as the table or after the table is created.
D. You must provide a name for each constraint at the time of its creation.
E. Constraint names are NOT required to follow the standard object-naming rules.
Answer: B & C
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 93 of 179
Explanation:
Constraints can be created at the table level and column level. They can be created at the time of
table creation or after the table is created. You cannot delete data from a table if there are
dependencies on the table. If you do not provide a name to the constraint then the oracle will
assign the name to constraint..
Question: 149. (G)
Examine the structure of the EMPLOYEE table.
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_LNAME VARCHAR2
(25)
EMP_FNAME VARCHAR2
(25)
DEPT_ID NUMBER Foreign key to DEPT_ID column of the
DEPARTMENT table
JOB_ID NUMBER Foreign key to JOB_ID column of the JOB table
MGR_ID NUMBER References EMPLOYEE_ID column
SALARY NUMBER (9,2)
HIRE_DATE DATE
Which CREATE TABLE statement should you use to create the EMPLOYEE table?
A. CREATE TABLE employee (
employee_id NUMBER,
emp_lname VARCHAR2(25),
emp_fname VARCHAR2(25),
dept_id NUMBER,
job_id NUMBER,
mgr_id NUMBER,
salary NUMBER(9,2),
hire_date DATE,
CONSTRAINT employee_id_pk PRIMARY KEY(employee_id),
CONSTRAINT dept_id_fk FOREIGN KEY(dept_id) REFERENCES department(dept_id),
CONSTRAINT job_id_fk FOREIGN KEY(job_id) REFERENCES job(job_id),
CONSTRAINT mgr_id_fk FOREIGN KEY(mgr_id) REFERENCES employee(emp_id));
B. CREATE TABLE employee (
employee_id NUMBER,
emp_lname VARCHAR2(25),
emp_fname VARCHAR2(25),
dept_id NUMBER,
job_id NUMBER,
mgr_id NUMBER,
salary NUMBER(9,2),
hire_date DATE,
CONSTRAINT employee_id_pk PRIMARY KEY(employee_id));
C. CREATE TABLE employee (
employee_id NUMBER,
emp_lname VARCHAR2(25),
emp_fname VARCHAR2(25),
dept_id NUMBER,
job_id NUMBER,
mgr_id NUMBER,
salary NUMBER(9,2),
hire_date DATE,
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 94 of 179
CONSTRAINT employee_id_pk PRIMARY KEY(employee_id),
CONSTRAINT dept_id_fk FOREIGN KEY(dept_id) REFERENCES department(dept_id),
CONSTRAINT job_id_fk FOREIGN KEY(job_id) REFERENCES job(job_id));
D. CREATE TABLE employee (
employee_id NUMBER,
emp_lname VARCHAR2(25),
emp_fname VARCHAR2(25),
dept_id NUMBER,
job_id NUMBER,
mgr_id NUMBER,
salary NUMBER(9,2),
hire_date DATE,
CONSTRAINT employee_id_pk PRIMARY KEY(employee_id),
CONSTRAINT mgr_id_fk FOREIGN KEY(mgr_id) REFERENCES employee(emp_id));
Answer: A
Explanation:
Employee Table will all constraints can be created by the following command.
CREATE TABLE employee (
employee_id NUMBER,
emp_lname VARCHAR2(25),
emp_fname VARCHAR2(25),
dept_id NUMBER,
job_id NUMBER,
mgr_id NUMBER,
salary NUMBER(9,2),
hire_date DATE,
CONSTRAINT employee_id_pk PRIMARY KEY(employee_id),
CONSTRAINT dept_id_fk FOREIGN KEY(dept_id) REFERENCES department(dept_id),
CONSTRAINT job_id_fk FOREIGN KEY(job_id) REFERENCES job(job_id),
CONSTRAINT mgr_id_fk FOREIGN KEY(mgr_id) REFERENCES employee(emp_id));
Question: 150. (G)
Which syntax turns an existing constraint on?
A. ALTER TABLE table_name
ENABLE constraint_name;
B. ALTER TABLE table_name
STATUS = ENABLE CONSTRAINT constraint_name;
C. ALTER TABLE table_name
ENABLE CONSTRAINT constraint_name;
D. ALTER TABLE table_name
STATUS ENABLE CONSTRAINT constraint_name;
E. ALTER TABLE table_name
TURN ON CONSTRAINT constraint_name;
F. ALTER TABLE table_name
TURN ON CONSTRAINT constraint_name;
Answer: C
Explanation:
ALTER TABLE statement with ENABLE CONSTRAINT keywords is correct answer to enable an
existing constraint.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 95 of 179
Incorrect Answers
A: This statement is missing CONSTRAINT keyword.
B: “STATUS =” is incorrect syntax to enable constraint for the table.
D: There is no STATUS keyword in the command to enable constraint.
E: There is no TURN ON keywords in the command to enable constraint.
F: There is no TURN ON keywords in the command to enable constraint.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 239-240
Chapter 5: Creating Oracle Database Objects
Question: 151. (G)
Which two statements about creating constraints are true? (Choose two)
A. Constraint names must start with SYS_C.
B. All constraints must be defines at the column level.
C. Constraints can be created after the table is created.
D. Constraints can be created at the same time the table is created.
E. Information about constraints is found in the VIEW_CONSTRAINTS dictionary view.
Answer: C & D
Explanation:
Constraints can be created after the table is created. Use ALTER TABLE command for that.
Constraints can be created at the same time the table is created (CREATE TABLE command).
Incorrect Answers
A: There is no requirements in Oracle that constraint names must start with SYS_C. Oracle can
use prefix “SYS” to build indexes for UNIQUE and NOT NULL constraints, but it is not required
for user to follow this naming rule.
B: Not all constraints must be defines at the column level. Only NOT NULL constraint must be.
E: There is no VIEW_CONSTRAINTS dictionary view in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 227-232
Chapter 5: Creating Oracle Database Objects
Question: 152. (G)
Which constraint can be defines only at the column level?
A. UNIQUE
B. NOT NULL
C. CHECK
D. PRIMARY KEY
E. FOREIGN KEY
Answer: B
Explanation:
The NOT NULL constraint can be defined only at the column level. It enforces that a value must
be defined for this column such that the column may not be NULL for any row.
Incorrect Answers
A: The UNIQUE constraint enforces uniqueness on values in the constrained column. It can be
defined not only at the column level.
C: The CHECK constraint enforces that values added to the constrained column must be present
in a static list of values permitted for the column.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 96 of 179
D: The PRIMARY KEY constraint stipulates that values in the constrained column(s) must be
unique and not NULL. If the primary key applies to multiple columns, then the combination of
values in the columns must be unique and not NULL.
E: The FOREIGN KEY constraint enforces that only values in the primary key of a parent table
may be included as values in the constrained column(s) of the child table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 227-232
Chapter 5: Creating Oracle Database Objects
Question: 153. (G)
Which statement explicitly names a constraint?
A. ALTER TABLE student_grades
ADD
FOREIGN KEY (student_id) REFERENCES students(student_id);
B. ALTER TABLE student_grades
ADD CONSTRAINT NAME = student_id_fk
FOREIGN KEY (student_id) REFERENCES students(student_id);
C. ALTER TABLE student_grades
ADD CONSTRAINT student_id_fk
FOREIGN KEY (student_id) REFERENCES students(student_id);
D. ALTER TABLE student grades
ADD NAMED CONSTRAINT student_id_fk
FOREIGN KEY (student_id) REFERENCES students(student_id);
E. ALTER TABLE student grades
ADD NAME student_id_fk
FOREIGN KEY (student_id) REFERENCES students(student_id);
Answer: C
Explanation:
This statement provides correct syntax to add a foreign key constraint to the existing table.
Incorrect Answers
A: The ADD FOREIGN KEY is wrong construction to add a foreign key constraint to the existing
table.
B: The ADD CONSTRAINT NAME is wrong construction to add a foreign key constraint to the
existing table.
D: The ADD NAMED CONSTRAINT is wrong construction to add a foreign key constraint to the
existing table.
E: The ADD NAME is wrong construction to add a foreign key constraint to the existing table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 238-239
Chapter 5: Creating Oracle Database Objects
Question: 154. (G)
Examine the SQL statements that creates ORDERS table:
CREATE TABLE orders
(SER_NO NUMBER UNIQUE,
ORDER_ID NUMBER,
ORDER_DATE DATE NOT NULL
STATUS VARCHARD2(10)
CHECK (status IN (‘CREDIT’,’CASH’)),
PROD_ID_NUMBER
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 97 of 179
REFERENCES PRODUCTS(PRODUCT_ID),
ORD_TOTAL NUMBER,
PRIMARY KEY (order id, order date));
For which columns would an index be automatically created when you execute the above SQL
statement? (Choose two)
A. SER_NO
B. ORDER_ID
C. STATUS
D. PROD_ID.
E. ORD_TOTAL
F. Composite index on ORDER_ID and ORDER_DATE
Answer: A & F
Explanation:
Indexes are created automatically by Oracle to support integrity constraints that enforce
uniqueness. The two types of integrity constraints that enforce uniqueness are PRIMARY KEY
and UNIQUE constraints. When the primary key or UNIQUE constraint is declared, a unique
index to support the column’s uniqueness is also created, and all values in all columns that were
defined as part of the primary key or UNIQUE constraint are placed into the index.
Incorrect Answers
B: There will not be index for ORDER_ID column.
C: There will not be index for STATUS column.
D: There will not be index for PROD_ID column.
E: There will not be index for ORD_TOTAL column.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 237-238
Chapter 5: Creating Oracle Database Objects
Question: 155. (G)
For which two constraints does the Oracle Server implicitly create a unique index?
(Choose two.)
A. NOT NULL.
B. PRIMARY KEY
C. FOREIGN KEY
D. CHECK
E. UNIQUE
Answer: B & E
Explanation:
Indexes are created automatically by Oracle to support integrity constraints that enforce
uniqueness. The two types of integrity constraints that enforce uniqueness are PRIMARY KEY
and UNIQUE constraints. When the primary key or UNIQUE constraint is declared, a unique
index to support the column’s uniqueness is also created, and all values in all columns that were
defined as part of the primary key or UNIQUE constraint are placed into the index.
Incorrect Answers
A: Oracle will not implicitly create an unique index for the NOT NULL constraint.
C: Oracle will not implicitly create an unique index for the FOREIGN KEY constraint.
D: Oracle will not implicitly create an unique index for the FOREIGN KEY constraint.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 98 of 179
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 237-238
Chapter 5: Creating Oracle Database Objects
Question: 156. (G)
Your attempt to disable a constraints result in the following error
Ora:02297: cannot disable constraint – dependencies exist.
Which of the following types of the constraints is likely causing interference with your disablement
of this one?
A. Check constraints.
B. Not NULL constraints.
C. Foreign key Constraints.
D. Unique Constraints.
Answer: C
Explanation:
When you attempt to disable a primary key when existing foreign keys depend on that primary
key. Then you will get this above shown error. To disable the column with primary key you have
to use an additional option CASCADE within the command.
Question: 157.(H)
Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHARD2(25)
LAST_NAME VARCHARD2(25)
HIRE_DATE DATE
NEW EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which UPDATE statement is valid?
A. UPDATE new_employees SET name = (Select last_name||.
first_name
FROM employees
Where employee_id =180)
WHERE employee_id =180;
B. UPDATE new_employees SET name = (SELECT
last_name||first_name
FROM employees)
WHERE employee_id =180;
C. UPDATE new_employees SET name = (SELECT last_name||
first_name
FROM employees
WHERE employee_id =180)
WHERE employee_id =(SELECT employee_id
FROM new employees);
D. UPDATE new_employees SET name = (SELECT last name||
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 99 of 179
first_name
FROM employees
WHERE employee_id=
(SELECT employee_id
FROM new_employees))
WHERE employee_id =180;
Answer: A
Explanation:
Sub-query in this answer will return one row value, concatenated first and last name for the
employee with ID 180, so update will be successful. When sub-queries are linked to the parent by
equality comparisons, the parent query expects only one row of data from the subquery.
Incorrect Answers
B: Sub-query will return concatenated first and last name for ALL records from the table
EMPLOYEES. It will cause an error for the parent query, because it expects one only one row.
C: Last WHERE statement in this query will generate error because sub-query returns multirow
result.
D: SELECT statement for the NEW_EMPLOYEES table in this query will generate error because
sub-query returns multi-row result.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 150-156
Chapter 4: Subqueries
Question: 158. (H)
Examine the structure if the EMPLOYEES and NEW EMPLOYEES tables:
EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
NEW EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which MERGE statement is valid?
A. MERGE INTO new_employees c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET
c.name = e.first_name ||’,’|| e.last_name
WHEN NOT MATCHED THEN
INSERT VALUES(e.employee_id, e.first_name ||’,
‘||e.last_name);
B. MERGE new_employees c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN EXIST THEN
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 100 of 179
UPDATE SET
c.name = e.first_name ||’,’|| e.last_name
WHEN NOT MATCHED THEN
INSERT VALUES(e.employee_id, e.first_name ||’,.
‘||e.last_name);
C. MERGE INTO new employees c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN EXISTS THEN
UPDATE SET
c.name = e.first_name ||’,’|| e.last_name
WHEN NOT MATCHED THEN
INSERT VALUES(e.employee_id, e.first_name ||’,
‘||e.last_name);
D. MERGE new_employees c
FROM employees e
ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET
c.name = e.first_name ||’,’|| e.last_name
WHEN NOT MATCHED THEN
INSERT INTO new_employees VALUES(e.employee_id, e.first_name
||’.’||e.last_name);
Answer: A
Explanation:
Correct syntax for the MERGE command is MERGE INTO table1 USING table2 on
(join_condition) WHEN MATCHED UPDATE SET col1 = value WHEN NOT MATCHED INSERT
(column_list) values (column_values).
Incorrect Answers
B: WHEN EXIST THEN clause cannot be used in the MERGE statement.
C: WHEN EXIST THEN clause cannot be used in the MERGE statement.
D: FROM clause cannot be used in the MERGE statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 273-275
Chapter 6: Manipulating Oracle Data
Question: 159. (H)
Examine the data in the EMPLOYEES and EMP_HIST tables:
EMPLOYEES
EMPLOYEE_ID NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 IT_ADMIN 5000
106 Smith 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EX_DIR 8000
120 Ravi 20 110 SA_DIR 6500
EMP_HIST
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 101 of 179
EMPLOYEE_ID NAME JOB_ID SALARY
101 Smith SA_CLERK 2000
103 Chris IT_CLERK 2200
104 John HR_CLERK 2000
106 Smith AD_ASST 3000
108 Jennifer HR_MGR 4500
The EMP_HIST table is updated at the end of every year. The employee ID, name, job ID, and
salary of each existing employee are modified with the latest data. New employee details are
added to the table.
Which statement accomplishes this task?
A. UPDATE emp_hist
SET employee_id, name, job_id, salary =
(SELECT employee_id, name, job_id, salary
FROM employees)
WHERE employee_id IN
(SELECT employee_id
FROM employees);
B. MERGE INTO emp_hist eh
USING employees e
ON (eh.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET eh.name = e.name,
eh.job_id = e.job_id,
eh.salary = e.salary
WHEN NOT MATCHED THEN
INSERT VALUES (e.employee id, e.name,
e.job id, e.salary);
C. MERGE INTO emp_hist eh
USING employees e
ON (eh.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE emp hist SET eh.name = e.name,
eh.job_id = e.job_id,
eh.salary = e.salary
WHEN NOT MATCHED THEN
INSERT INTO emp_hist
VALUES (e.employee_id, e.name, e.job_id, e.salary);
D. MERGE INTO emp_hist eh
USING employees e.
WHEN MATCHED THEN
UPDATE emp_hist SET eh.name = e.name,
eh.job_id = e.job_id,
eh.salary = e.salary
WHEN NOT MATCHED THEN
INSERT INTO emp_hist
VALUES (e.employee_id, e.name, e.job_id, e.salary);
Answer: B
Explanation:
This task can be done using the MERGE command. Correct syntax for the MERGE command is
MERGE INTO table1 USING table2 on (join_condition) WHEN MATCHED UPDATE
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 102 of 179
SET col1 = value WHEN NOT MATCHED INSERT (column_list) values (column_values).
Incorrect Answers
A: MERGE command can handle this task, not UPDATE: new employee details will not be added
to the table
C: This statement would by correct if UPDATE SET is syntax used, not UPDATE table_name
SET syntax as in usual UPDATE command.
D: “ON condition” clause of the MERGE command is absent.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 273-275
Chapter 6: Manipulating Oracle Data
Question: 160. (H)
Which are DML statements? (Choose all that apply)
A. COMMIT…
B. MERGE…
C. UPDATE…
D. DELETE…
E. CREATE…
F. DROP…
Answer: B, C & D
Explanation:
MERGE, UPDATE and DELETE commands are data manipulation language (DML) statements.
Incorrect Answers
A: COMMIT is not a DML command.
E: CREATE is a data definition language (DDL) command.
F: DROP is a data definition language (DDL) command.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 267-279
Chapter 6: Manipulating Oracle Data
Question: 161. (H)
Examine the data in the EMPLOYEES and DEPARTMENTS tables:
EMPLOYEES
EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 IT_ADMIN 5000
106 Smith 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 110 EX_DIR 8000
120 Ravi 20 110 SA*DIR 6500
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 103 of 179
DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME
10 Admin
20 Education
30 IT
40 Human Resources
Also examine the SQL statements that create the EMPLOYEES and DEPARTMENTS tables:
CREATE TABLE departments
(department_id NUMBER PRIMARY KEY,
department_name VARCHAR2(30));
CREATE TABLE employees
(EMPLOYEE_ID NUMBER PRIMARY KEY,
EMP_NAME VARCHAR2(20),
DEPT_ID NUMBER REFERENCES
departments(department_id),
MGR_ID NUMBER REFERENCES
employees(employee id),
MGR_ID NUMBER REFERENCES
employees(employee id),
JOB_ID VARCHAR2(15).
SALARY NUMBER);
ON the EMPLOYEES,
On the EMPLOYEES table, EMPLOYEE_ID is the primary key.
MGR_ID is the ID of managers and refers to the EMPLOYEE_ID.
DEPT_ID is foreign key to DEPARTMENT_ID column of the DEPARTMENTS table.
On the DEPARTMENTS table, DEPARTMENT_ID is the primary key.
Examine this DELETE statement:
DELETE
FROM departments
WHERE department id = 40;
What happens when you execute the DELETE statement?
A. Only the row with department ID 40 is deleted in the DEPARTMENTS table.
B. The statement fails because there are child records in the EMPLOYEES table with
department ID 40.
C. The row with department ID 40 is deleted in the DEPARTMENTS table. Also the rows with
employee IDs 110 and 106 are deleted from the EMPLOYEES table.
D. The row with department ID 40 is deleted in the DEPARTMENTS table. Also the rows with
employee IDs 106 and 110 and the employees working under employee 110 are deleted from
the EMPLOYEES table.
E. The row with department ID 40 is deleted in the DEPARTMENTS table. Also all the rows in
the EMPLOYEES table are deleted.
F. The statement fails because there are no columns specifies in the DELETE clause of the
DELETE statement.
Answer: B
Explanation:
It will be error generated because there are 2 child records in the EMPLOYEES table with
department number you try to delete from the DEPARTMENTS table.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 104 of 179
Incorrect Answers
A: The row with department ID 40 will not be deleted because of the child records in the
EMPLOYEES table.
C: Neither the row with department ID 40 will not be deleted not child records in the
EMPLOYEES table will be deleted.
D: It will be error when you try to execute the DELETE statement, no rows will be deleted in the
EMPLOYEES or the DEPARTMENTS tables.
E: It will be error when you try to execute the DELETE statement, no rows will be deleted in the
EMPLOYEES or the DEPARTMENTS tables.
F: The statement fails because of constraint violation not because there are no columns specifies
in the DELETE clause of the DELETE statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 240-245
Chapter 5: Creating Oracle Database Objects
Question: 162. (H)
You maintain two tables, CUSTOMER and PROSPECT, that have identical structures but
different data. You want to synchronize these two tables by inserting records from the
PROSPECT table into the CUSTOMER table, if they do not exist. If the customer already exists in
the CUSTOMER table, you want to update customer data.
Which DML statement should you use to perform this task?
A. INSERT
B. UPDATE
C. SYNC
D. MERGE
E. You CANNOT perform this task with one DML operation.
Answer: D
Explanation:
MERGE command can be use to synchronize the two tables. when this command is used then if
the data already exist then it will be updated and if does not exist then these two tables will be
synchronize by inserting the data from one table to the other.
Question: 163. (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL
EMP_NAME VARCHAR2(30)
JOB_ID VARCHAR2(20) DEFAULT 'SA_REP'
SAL NUMBER
COMM_PCT NUMBER
MGR_ID NUMBER.
DEPARTMENT_ID NUMBER
You need to update the records of employees 103 and 115. The UPDATE statement you specify
should update the rows with the values specified below:
JOB_ID: Default value specified for this column definition.
SAL: Maximum salary earned for the job ID SA_REP.
COMM_PCT: Default value specified for this commission percentage column, if any.
If no default value is specified for the column, the value should be NULL.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 105 of 179
DEPARTMENT_ID: Supplied by the user during run time through substitution variable.
Which UPDATE statement meets the requirements?
A. UPDATE employees
SET job_id = DEFAULT
AND Sal = (SELECT MAX(sal)
FROM employees
WHERE job_id = 'SA_REP'
AND comm_pct = DEFAULT
AND department_id = &did
WHERE employee_id IN (103,115);
B. UPDATE employees
SET job_id = DEFAULT
AND Sal = MAX(sal)
AND comm_pct = DEFAULT OR NULL
AND department_id = &did
WHERE employee_id IN (103,115)
AND job_id = 'SA_REP';
C. UPDATE employees
SET job_id = DEFAULT,
Sal = (SELECT MAX(sal)
FROM employees
WHERE job_id = 'SA_REP'),
comm_pct = DEFAULT,
department_id = &did
WHERE employee_id IN (103,115);
D. UPDATE employees
SET job_id = DEFAULT,
Sal = MAX(sal),
comm_pct = DEFAULT,
department_id = &did
WHERE employee_id IN (103,115)
AND job_id = 'SA_REP';
E. UPDATE employees.
SET job_id = DEFAULT,
Sal = (SELECT MAX(sal)
FROM employees
WHERE job_id = 'SA_REP')
comm_pct = DEFAULT OR NULL,
department_id = &did
WHERE employee_id IN (103,115);
Answer: C
Explanation:
This UPDATE statement is correct to receive desired results. Correct syntax is UPDATE
table_name SET column_name1 = value, column_name2 = value2. You can also use the
DEFAULT keyword to set a column value to its specified default value in update statements as
well.
Incorrect Answers
A: You cannot use syntax like UPDATE table_name SET column_name1 = value AND
column_name2 = value2. Correct syntax is UPDATE table_name SET column_name1 = value,
column_name2 = value2.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 106 of 179
B: You cannot use syntax like UPDATE table_name SET column_name1 = value AND
column_name2 = value2. Correct syntax is UPDATE table_name SET column_name1 = value,
column_name2 = value2.
D: Group function is not allowed to use in the SET clause of the UPDATE command.
E: You cannot set column to value DEFAULT OR NULL: this is wrong syntax to use.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 267-270
Chapter 6: Manipulating Oracle Data
Question: 164. (H)
You added a PHONE-NUMBER column of NUMBER data type to an existing EMPLOYEES table.
The EMPLOYEES table already contains records of 100 employees. Now, you want to enter the
phone numbers of each of the 100 employees into the table.
Some of the employees may not have a phone number available.
Which data manipulation operation do you perform?
A. MERGE
B. INSERT
C. UPDATE
D. ADD
E. ENTER
F. You cannot enter the phone numbers for the existing employee records.
Answer: C
Explanation:
To update information you need to use UPDATE command.
Incorrect Answers
A: Since you don’t have to add any records to the table you don’t need the MERGE command.
B: Since you don’t have to add any records to the table you don’t need the MERGE command.
D: There is no ADD command in Oracle.
E: There is no ENTER command in Oracle.
F: You can enter the phone numbers for the existing employee records by using UPDATE
command.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 267-270
Chapter 3: Manipulating Oracle Data
Question: 165. (H)
Which two statements complete a transaction? (Choose two)
A. DELETE employees;
B. DESCRIBE employees;
C. ROLLBACK TO SAVEPOINT C;
D. GRANT SELECT ON employees TO SCOTT;
E. ALTER TABLE employees
SET UNUSED COLUMN sal;
F. Select MAX(sal)
FROM employees
WHERE department_id = 20;
Answer: D, E
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 107 of 179
Question: 166. (H)
Examine the data in the EMPLOYEES table.
EMPLOYEES
EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 IT_ADMIN 5000
106 Smith 40 110 AD.ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EK_DIR 8000
120 Revi 20 110 SA_DIR 6500
On the EMPLOYEES table, EMPLOYEE_ID is the primary key. MGR_ID is the ID of managers
and refers to the EMPLOYEE_ID. The JOB_ID column is a NOT NULL column.
Evaluate this DELETE statement:
DELETE employee_id, salary, job_id
FROM employees
WHERE dept_id = 90;
Why does the DELETE statement fail when you execute it?
A. There is no row with dept_id 90 in the EMPLOYEES table.
B. You cannot delete the JOB_ID column because it is a NOT NULL column.
C. You cannot specify column names in the DELETE clause of the DELETE statement.
D. You cannot delete the EMPLOYEE_ID column because it is the primary key of the table.
Answer: C
Explanation:
You cannot specify column names in the DELETE clause of the DELETE statement. Syntax of
this command is: DELETE FROM table_name WHERE column_name = value.
Incorrect Answers
A: Error in this statement is related with list of columns in the DELETE statement, not with
absence of row with DEPT_ID = 90 in the EMPLOYEES table.
B: Error in this statement is related with list of columns in the DELETE statement, not with NOT
NULL constraint on the JOB_ID column.
D: Error in this statement is related with list of columns in the DELETE statement, not with the
primary key constraint on the EMPLOYEE_ID column.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 270-273
Chapter 6: Manipulating Oracle Data
Question: 167. (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCNAR2(25)
LAST_NAME VARCNAR2(25)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 108 of 179
Which three statements inserts a row into the table? (Choose three)
A. INSERT INTO employees
VALUES ( NULL, ‘John’,‘Smith’);
B. INSERT INTO employees( first_name, last_name)
VALUES(‘John’,‘Smith’);
C. INSERT INTO employees
VALUES (‘1000’,‘John’,NULL);
D. INSERT INTO employees(first_name,last_name, employee_id)
VALUES ( 1000, ‘John’,‘Smith’);
E. INSERT INTO employees (employee_id)
VALUES (1000);
F. INSERT INTO employees (employee_id, first_name, last_name)
VALUES ( 1000, ‘John’,‘’);
Answer: C, E, F
Explanation:
Since EMPLOYEE_ID column is used as primary key, it cannot be NULL, so only INSERT
statements in C, E and F are correct. You can insert the row with NULL LAST_NAME as in
answer C, or only the row with EMPLOYEE_ID as in answer E, or the row with empty
LAST_NAME column.
Incorrect Answers
A: This answer is incorrect because a primary key cannot be NULL.
B: INSERT statement does not contain primary key value at all, so this answer needs to be
eliminated as correct one.
D: This statement shows incorrect order of columns of row which needs to be inserted into the
table.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 260-267
Chapter 6: Manipulating Oracle Data
Question: 168. (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
You issue these statements:
CREATE table new_emp ( employee_id NUMBER, name VARCHAR2(30));
INSERT INTO new_emp SELECT employee_id , last_name from
employees;
Savepoint s1;
UPDATE new_emp set name = UPPER(name);
Savepoint s2;
Delete from new_emp;
Rollback to s2;
Delete from new_emp where employee_id =180;
UPDATE new_emp set name = 'James';
Rollback to s2;
UPDATE new_emp set name = 'James' WHERE employee_id =180;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 109 of 179
Rollback;
At the end of this transaction, what is true?
A. You have no rows in the table.
B. You have an employee with the name of James.
C. You cannot roll back to the same savepoint more than once.
D. Your last update fails to update any rows because employee ID 180 was already deleted.
Answer: A
Explanation:
At the end of this transaction you will not have rows in the table.
Incorrect Answers
B: All transactions will be roll backed, so it will be no rows in the table.
C: It is possible to roll back to the same savepoint more than once.
D: Your last update will not fail because there is employee with ID 180 in the table and
transactions have been rolled back only to the savepoint s2 before issue this update.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 279-285
Chapter 6: Manipulating Oracle Data
Question: 169. (H)
Examine the data from the CLASS and INSTRUCTOR tables.
CLASS Table
CLASS_ID CLASS_NAME HOURS_CREDIT INSTRUCTOR_ID
1 Introduction to Accounting 3 4
2 Computer Basics 3 1
3 Tax Accounting Principles 3 4
4 American History 3 2
5 Basic Engineering 3
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 110 of 179
INSTRUCTOR Table
INSTRUCTOR_ID LAST_NAME FIRST_NAME
1 Chao Ling
2 Vanderbilt Herbert
3 Wigley Martha
4 Page Albert
You want to delete the classes that do NOT have an instructor assigned. Which DELETE
statement will accomplish the desired result?
A. DELETE class_id, class_name, hours_credit, instructor_id
FROM class
WHERE instructor_id IS NULL;
B. DELETE FROM class
WHERE instructor_id NOT IN
(SELECT instructor_id
FROM class);
C DELETE FROM
instructor NATURAL JOIN class
WHERE instructor_id IS NOT NULL;
D. DELETE FROM class
WHERE instructor_id IS NULL;
Answer: D
Explanation:
To delete a record from a table on the basis of null values you can use the IS NULL operator in
the condition in delete statement as
DELETE FROM class
WHERE instructor_id IS NULL;
Question: 170. (H)
Which action will cause an automatic rollback?
A. GRANT statement
B. CREATE statement
C. System crash
D. exiting from iSQL*Plus without first committing the changes
E. subsequent DML statement
F. SAVEPOINT statement
Answer: C
Explanation:
Automatic roll back occur under an abnormal termination of SQL Plus and when the system
crashes or machines fails.
Question: 171. (H)
The PRODUCT table contains these columns:
PRODUCT_ID NUMBER NOT NULL
PRODUCT_NAME VARCHAR2(25)
SUPPLIER_ID NUMBER
LIST_PRICE NUMBER(7,2)
COST NUMBER(7,2)
You need to increase the list price and cost of all products supplied by Global Imports, Inc. by 5.5
percent. The SUPPLIER_ID for Global Imports, Inc. is 105. Which statement should you use?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 111 of 179
A. UPDATE product
SET list_price = list_price * 1.055
SET cost = cost * 1.055
WHERE supplier_id = 105;
B. UPDATE product
SET list_price = list_price * .055 AND
cost = cost * .055
WHERE supplier_id = 105;
C. UPDATE product
SET list_price = list_price * 1.055, cost = cost * 1.055
WHERE supplier_id = 105;
D. UPDATE product
SET list_price = list_price + (list_price * .055), cost = cost + (cost * .055)
WHERE supplier_id LIKE 'Global Imports, Inc.'
OR supplier_id = 105;
E. UPDATE product
SET list_price = list_price + (list_price * .055), cost = cost + (cost * .055)
WHERE supplier_id LIKE 'Global Imports, Inc.';
Answer: C
Explanation:
Using UPDATE command you can change the data of a table. To increase the value of list price
and cost of all products supplied by Global imports, Inc by 5.5 percent and the SUPPLIER_ID for
global imports. Inc is 105 use the following command
UPDATE product
SET list_price = list_price * 1.055, cost = cost * 1.055
WHERE supplier_id = 105;
Question: 172. (H)
Which two statements would cause an implicit COMMIT to occur? (Choose two.)
A. GRANT
B. UPDATE
C. COMMIT
D. SELECT
E. ROLLBACK
F. RENAME
Answer: A & F
Explanation:
All DDL commands such as CREATE, ALTER, DROP and all DCL commands such GRANT and
REVOKE cause an implicit commit. RENAME command also change the definition of object so
this is will also cause an implicit commit.
Question: 173. (H)
Examine the structures of the EVENT and NEW_EVENT tables.
EVENT Table
EVENT_ID NUMBER
EVENT_NAME VARCHAR2 (30)
EVENT_DESCRIPTION VARCHAR2 (100)
EVENT_TYPE_ID NUMBER
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 112 of 179
NEW_EVENT Table
EVENT_ID NUMBER
EVENT_NAME VARCHAR2 (30)
EVENT_DESCRIPTION VARCHAR2 (100)
EVENT_TYPE_ID NUMBER
START_DT DATE
You execute this MERGE statement:
MERGE INTO EVENT e
USING (SELECT *
FROM new_event
WHERE event_type_id = 4) n
ON (e.event_id = n.event_id)
WHEN MATCHED THEN
UPDATE SET
e.event_type_id = n.event_type_id,
e.start_dt = n.start_dt
WHEN NOT MATCHED THEN
INSERT (event_id, event_name, event_type_id)
VALUES(n.event_id, n.event_name, n.event_type_id);
This MERGE statement generates an error. Which statement describes the cause of the error?
A. A subquery CANNOT be used in the USING clause of a MERGE statement.
B. Table aliases CANNOT be used in a MERGE statement.
C. The ON clause of the statement is invalid.
D. The UPDATE portion of the statement is invalid.
E. The INSERT portion of the statement is invalid.
F. A MERGE statement CANNOT be used with tables that do NOT have an identical structure.
Answer: D
Explanation:
Use the MERGE statement to select rows from one table for update or insertion into another
table. The decision whether to update or insert into the target table is based on a condition in the
ON clause. In the above written statement the update portion contains invalid column name as no
START_ID column is in the EVENT table.
Question: 174. (H)
Which statement regarding DML statement functionality is true?
A. DELETE can be used to delete rows or columns from a table.
B. MERGE will delete rows that do NOT exist in either table.
C. UPDATE will add rows to a table if an INTO clause is specified.
D. UPDATE can update multiple columns in one table.
E. INSERT must contain a VALUES clause.
Answer: D
Explanation:
UPDATE commands can update multiple columns in one table by using comma (,) between the
columns in a single statement.
Question: 175. (H)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 113 of 179
The STUDENT table contains these columns:
STU_ID NUMBER(9) NOT NULL
LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(25) NOT NULL
DOB DATE
STU_TYPE_ID VARCHAR2(1) NOT NULL
ENROLL_DATE DATE
You create another table, named PT_STUDENT, with an identical structure. You want to insert all
part-time students, who have a STU_TYPE_ID value of "P", into the new table. You execute this
INSERT statement:
INSERT INTO pt_student
(SELECT stu_id, last_name, first_name, dob, sysdate
FROM student
WHERE UPPER(stu_type_id) = 'P');
What is the result of executing this INSERT statement?
A. All part-time students are inserted into the PT_STUDENT table.
B. An error occurs because the PT_STUDENT table already exists.
C. An error occurs because you CANNOT use a subquery in an INSERT statement.
D. An error occurs because the STU_TYPE_ID column is NOT included in the subquery select
list.
E. An error occurs because both the STU_TYPE_ID and ENROLL_DATE columns are NOT
included in the subquery select list.
F. An error occurs because the INSERT statement does NOT contain a VALUES clause.
Answer: D
Explanation:
When using subquery to insert data into the table do not use the VALUES clause and the number
of columns in the INSERT clause must match to number of column in the subquery. In the above
written statement STU_TYPE_ID column is in the pt_student table but is missing in the subquery
select list so this will cause an error.
Question: 176. (H)
Examine the structures of the AR_TRX and AR_TRX_HY tables.
AR_TRX Table
TRX_ID NUMBER NOT NULL, Primary Key
TRX_TYPE VARCHAR2 (5)
QUANTITY NUMBER
UNIT_PRICE NUMBER (7,2)
EXT_AMT NUMBER (9,2)
TAX_AMT NUMBER (7,2)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 114 of 179
AR_TRX Table
TRX_ID NUMBER NOT NULL, Primary Key
TRX_TYPE VARCHAR2 (5)
QUANTITY NUMBER
UNIT_PRICE NUMBER (7,2)
EXT_AMT NUMBER (9,2)
TAX_AMT NUMBER (7,2)
GRAND_TOTAL NUMBER (10,2)
LOAD_DATE DATE
You are loading historical accounts receivable data from the AR_TRX table into the AR_TRX_HY
table. During the load, you want to transform the data so that the GRAND_TOTAL column of the
AR_TRX_HY table is equal to the sum of the EXT_AMT and TAX_AMT columns in the AR_TRX
table. You want to set LOAD_DATE to the current date. If the record already exists in the target
table, all values, except TRX_ID and TRX_TYPE, should be refreshed with the most recent data.
Which MERGE statement should you execute?
A. MERGE INTO ar_trx_hy h
USING ar_trx a
ON (h.trx_id = a.trx_id)
WHEN MATCHED THEN
UPDATE SET
a.quantity = h.quantity,
a.unit_price = h.unit_price,
a.ext_amt = h.ext_amt,
a.tax_amt = h.tax_amt,
a.grand_total = h.ext_amt + h.tax_amt,
a.load_date = sysdate
WHEN NOT MATCHED THEN
INSERT VALUES(a.trx_id, a.trx_type, a.quantity, a.unit_price,
a.ext_amt, a.tax_amt, a.ext_amt + a.tax_amt, sysdate);
B. MERGE INTO ar_trx_hy
USING ar_trx
USING (trx_id)
WHEN MATCHED THEN
UPDATE SET
quantity = quantity,
unit_price = unit_price,
ext_amt = ext_amt,
tax_amt = tax_amt,
grand_total = ext_amt + tax_amt,
load_date = sysdate
WHEN NOT MATCHED THEN
INSERT VALUES(trx_id, trx_type, quantity, unit_price,
ext_amt, tax_amt, ext_amt + tax_amt, sysdate);
C. MERGE INTO ar_trx_hy h
USING ar_trx a
ON (h.trx_id = a.trx_id)
WHEN MATCHED THEN
UPDATE ar_trx_hy SET
h.quantity = a.quantity,
h.unit_price = a.unit_price,
h.ext_amt = a.ext_amt,
h.tax_amt = a.tax_amt,
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 115 of 179
h.grand_total = a.ext_amt + a.tax_amt,
h.load_date = sysdate
WHEN NOT MATCHED THEN
INSERT VALUES(a.trx_id, a.trx_type, a.quantity, a.unit_price,
a.ext_amt, a.tax_amt, a.ext_amt + a.tax_amt, sysdate);
D. MERGE INTO ar_trx_hy h
USING ar_trx a
ON (h.trx_id = a.trx_id)
WHEN MATCHED THEN
UPDATE SET
h.quantity = a.quantity,
h.unit_price = a.unit_price,
h.ext_amt = a.ext_amt,
h.tax_amt = a.tax_amt,
h.grand_total = a.ext_amt + a.tax_amt,
h.load_date = sysdate
WHEN NOT MATCHED THEN
INSERT VALUES(a.trx_id, a.trx_type, a.quantity, a.unit_price,
a.ext_amt, a.tax_amt, a.ext_amt + a.tax_amt, sysdate);
E. MERGE INTO ar_trx_hy h
USING ar_trx a
ON (h.trx_id = a.trx_id)
WHEN MATCHED
UPDATE SET
h.quantity = a.quantity,
h.unit_price = a.unit_price,
h.ext_amt = a.ext_amt,
h.tax_amt = a.tax_amt,
h.grand_total = a.ext_amt + a.tax_amt,
h.load_date = sysdate
WHEN NOT MATCHED
INSERT VALUES(a.trx_id, a.trx_type, a.quantity, a.unit_price,
a.ext_amt, a.tax_amt, a.ext_amt + a.tax_amt, sysdate);
Answer: D
Explanation:
Ans E contain the correct syntax for MERGE statement to performs all of the above desired
changes.
Question: 177. (H)
EMPLOYEES and DEPARTMENTS data:
EMPLOYEES
EMPLOYEE_ID EMP_NAME DEPT_ID MGR_ID JOB_ID SALARY
101 Smith 20 120 SA_REP 4000
102 Martin 10 105 CLERK 2500
103 Chris 20 120 IT_ADMIN 4200
104 John 30 108 HR_CLERK 2500
105 Diana 30 108 IT_ADMIN 5000
106 Smith 40 110 AD_ASST 3000
108 Jennifer 30 110 HR_DIR 6500
110 Bob 40 EX_DIR 8000
120 Ravi 20 110 SA_DIR 6500
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 116 of 179
DEPARTMENTS
DEPARTMENT_ID DEPARTMENT_NAME
10 Admin
20 Education
30 IT
40 Human Resources
On the EMPLOYEES table, EMPLOYEE_ID is the primary key. MGR_ID is the ID managers and
refers to the EMPLOYEE_ID.
On the DEPARTMENTS table DEPARTMENT_ID is the primary key.
Evaluate this UPDATE statement.
UPDATE employees
SET mgr_id =
(SELECT mgr_id
FROM employees
WHERE dept_id=
(SELECT department_id
FROM departments
WHERE department_name = 'Administration')),
Salary = (SELECT salary
FROM employees
WHERE emp_name = 'Smith')
WHERE job_id = 'IT_ADMIN';
What happens when the statement is executed?
A. The statement executes successfully, leaves the manager ID as the existing value, and
changes the salary to 4000 for the employees with ID 103 and 105.
B. The statement executes successfully, changes the manager ID to NULL, and changes the
salary to 4000 for the employees with ID 103 and 105.
C. The statement executes successfully, changes the manager ID to NULL, and changes the
salary to 3000 for the employees with ID 103 and 105.
D. The statement fails because there is more than one row matching the employee name Smith.
E. The statement fails because there is more than one row matching the IT_ADMIN job ID in the
EMPLOYEES table.
F. The statement fails because there is no 'Administration' department in the DEPARTMENTS
table.
Answer: D
Explanation :
'=' is use in the statement and subquery will return more than one row.
Employees table has 2 row matching the employee name Smith.
The update statement will fail.
Incorrect Answers :
A. The Update statement will fail no update was done.
B. The update statement will fail no update was done.
C. The update statement will fail no update was done.
E. The update statement will fail but not due to job_it='IT_ADMIN'
F. The update statement will fail but not due to department_id='Administration'
Reference:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 117 of 179
Introduction to Oracle9i : SQL, Oracle University Student Guide, Subqueries, p. 6-12
Question: 178. (H)
The transaction control which prevent more than one user from updating data in a table is which
of the following?
A. Lock.
B. Commit.
C. Rollback.
D. Savepoint.
Answer: A
Explanation:
A LOCK is the mechanism that prevents more than one user at a time from making changes to a
database. COMMIT, ROLLBACK & SAVEPOINT are the options which make end of the
transaction at different stages in a transaction.
Question: 179.(I)
What is necessary for your query on an existing view to execute successfully?
A. The underlying tables must have data.
B. You need SELECT privileges on the view.
C. The underlying tables must be in the same schema.
D. You need SELECT privileges only on the underlying tables.
Answer: B
Explanation:
To query an existing view you need to have SELECT privileges on the view.
Incorrect Answers
A: The underlying tables can be without data: view will work correctly in that case.
C: The underlying tables can be in different user schema.
D: You need SELECT privileges not only on the underlying tables, but on the view also.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-359
Chapter 8: User Access Control in Oracle
Question: 180. (I)
Examine the structure if the EMPLOYEES table:
Column name Data Type Remarks
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_NAME VARCHAR2(30)
JOB_ID VARCHAR2(20) NOT NULL
SAL NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID
column of the DEPARTMENTS table
You need to create a view called EMP_VU that allows the user to insert rows through the view.
Which SQL statement, when used to create the EMP_VU view, allows the user to insert rows?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 118 of 179
A. CREATE VIEW emp_Vu AS
SELECT employee_id, emp_name,
department_id
FROM employees
WHERE mgr_id IN (102, 120);
B. CREATE VIEW emp_Vu AS
SELECT employee_id, emp_name, job_id
department_id
FROM employees
WHERE mgr_id IN (102, 120);
C. CREATE VIEW emp_Vu AS
SELECT department_id, SUM(sal) TOTALSAL
FROM employees
WHERE mgr_id IN (102, 120)
GROUP BY department_id;
D. CREATE VIEW emp_Vu AS
SELECT employee_id, emp_name, job_id,
DISTINCT department_id
FROM employees;
Answer: B
Explanation:
This statement will create view that can be used to change tables in underlying table through
simple views. It includes primary key, NOT NULL column and foreign key to avoid constraint
restrictions.
Incorrect Answers
A: This statement does not include JOB_ID column that cannot be NULL. In general, all
constraint restrictions defined on the underlying table also apply to modifying data via the view.
For example, you can’t add data to an underlying table via a view that violates the table’s
primary key constraint.
C: You cannot update a column of an underlying table if the simple view use a single-row function
to define the column.
D: You may not insert, update, or delete records data on the table underlying the simple view if
the SELECT statement creating the view contains a GROUP BY clause, GROUP function, or
DISTINCT clause.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 298-299
Chapter 7: Creating Other Database Objects in Oracle
Question: 181. (I)
You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES
and DEPARTMENTS tables:
EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME.
The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key
DEPARTMENT_ID column of the DEPARTMENTS table.
You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type
from the EMPLOYEES tables.
How can you accomplish this task?
A. ALTER VIEW emp_dept_vu (ADD manager_id NUMBER);
B. MODIFY VIEW emp_dept_vu (ADD manager_id NUMBER);
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 119 of 179
C. ALTER VIEW emp_dept_vu AS
SELECT employee_id, employee_name,
department_name, manager_id
FROM employee e, departments d
WHERE e.department_id = d.department_id;
D. MODIFY VIEW emp_dept_vu AS
SELECT employee_id, employee_name,
department_name, manager_id
FROM employees e, departments d
WHERE e.department_id = d.department_id;
E. CREATE OR REPLACE VIEW emp_dept_vu AS
SELECT employee_id, employee_name,
department_name, manager_id
FROM employees e, departments d
WHERE e.department_id = d.department_id;
F. You must remove the existing view first, and then run the CREATE VIEW command with a
new column list to modify a view.
Answer: E
Explanation:
When we want to alter the underlying data used in the definition of a view, we use the CREATE
OR REPLACE VIEW statement. When a CREATE OR REPLACE VIEW statement is issued,
Oracle will disregard the error that arises when it encounters the view that already exists with that
name, and it will overwrite the definition for the old view with the definition for the new one.
Incorrect Answers
A: There is no ALTER VIEW command in Oracle.
B: There is no MODIFY VIEW command in Oracle.
C: There is no ALTER VIEW command in Oracle.
D: There is no MODIFY VIEW command in Oracle.
F: You don’t need to remove the existing view to create modified view. You are able to do that
with CREATE OR REPLACE command.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 310-313
Chapter 7: Creating Other Database Objects in Oracle
Question: 182. (I)
Which statements concerning the creation of a view are true? (Choose all that apply.)
A. A constraint name must be provided when using the WITH CHECK OPTION clause or the
statement will fail.
B. View columns that are the result of derived values must be given a column alias.
C. When the view already exists, using the OR REPLACE option requires the re-granting of the
object privileges previously granted on the view.
D. A view may have column names that are different than the actual base table(s) column
names by using column aliases.
Answer: B & D
Explanation:
View columns that are the result of derived values from any expressions must be given a column
alias and view may have column names that are different than the base table column names by
using column aliases.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 120 of 179
Question: 183. (I)
You are granted the CREATE VIEW privilege. What does this allow you to do?
A. Create a table view.
B. Create a view in any schema.
C. Create a view in your schema.
D. Create a sequence view in any schema.
E. Create a view that is accessible by everyone.
F. Create a view only of it is based on tables that you created.
Answer: C
Explanation:
You can create a view in your own schema only if you are granted the CREATE VIEW privilege.
Incorrect Answers
A: You can create a view in your own schema only.
B: You can create a view in your own schema only, not in any schema.
D: There is no sequence view in Oracle.
E: You cannot create a view that is accessible by everyone. You will need specially grant
SELECT privileges on this view for everyone.
F: You can create a view in your own schema, but not only for tables in your schema. You can
use object from other users schemas if you have privileges to retrieve data from them.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 292-301
Chapter 7: Creating Other Database Objects in Oracle
Question: 184. (I)
Examine the structure of the CURR_ORDER table as shown below:
CURR_ORDER Table
ORDER_ID NUMBER NOT NULL, Primary Key
CUSTOMER_ID NUMBER NOT NULL, Foreign Key to CUSTOMER_ID
column of the CUSTOMERS table
EMP_ID NUMBER NOT NULL, Foreign Key to EMP_ID column of
the EMPLOYEES table
ORDER_DT DATE NOT NULL
ORDER_AMT NUMBER (7,2)
SHIP_METHOD VARCHAR2 (5)
You created the ORDER_V view selecting all rows and columns from the ORDER table where
the amount of the order was over $250 and the date of the order was after January 1, 2000. The
CREATE VIEW statement included the WITH CHECK OPTION clause.
Which statement will execute successfully?
A. INSERT INTO order_v (order_id, customer_id, emp_id, order_dt, order_amt)
VALUES (840, 292, 104, '10-OCT-2001', 318);
B. INSERT INTO order_v (order_id, customer_id, emp_id, order_amt, ship_method)
VALUES (936, 292, 104, 256.3, 'UPXS');
C. INSERT INTO order_v (order_id, customer_id, emp_id, order_dt, order_amt, ship_method)
VALUES (164, 292, 104, '10-MAY-2001', 3.56, 'UPXS');
D. INSERT INTO order_v (order_id, customer_id, emp_id, order_dt, order_amt, ship_method)
VALUES (203, 292, 104, '10-OCT-1999', 298.4, 'UPXS');
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 121 of 179
Answer: A
Explanation:
Using WITH CHECK OPTION in the view creation you can ensure that all DML on the view stays
with in the domain of the view. In the above scenario you cannot insert a date before January 1,
2000 and the amount of the order should also be more than $250.
Question: 185. (I)
An inline view is a SELECT statement that is given an alias and is embedded in the ______
clause of another SELECT statement.
A. FROM
B. WHERE
C. SELECT
D. CASE
Answer: A
Explanation:
Inline view is a select statement that is embedded in the FROM clause of another SELECT
statement. You can use its result as a table.
Question: 186. (I)
You need to create a view EMP_VU. The view should allow the users to manipulate the records
of only the employees that are working for departments 10 or 20.
Which SQL statement would you use to create the view EMP_VU?
A. CREATE VIEW emp_vu AS
SELECT *
FROM employees
WHERE department_id IN (10,20);
B. CREATE VIEW emp_vu AS
SELECT *
FROM employees
WHERE department_id IN (10,20)
WITH READ ONLY;
C. CREATE VIEW emp_vu AS
SELECT *
FROM employees
WHERE department_id IN (10,20)
WITH CHECK OPTION;
D. CREATE FORCE VIEW emp_vu AS
SELECT *
FROM employees
WHERE department_id IN (10,20);
E. CREATE FORCE VIEW emp_vu AS
SELECT *
FROM employees
WHERE department_id IN (10,20)
NO UPDATE;
Answer: C
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 122 of 179
Tables that underlie views often have constraints that limit the data that can be added to those
tables. Views cannot add data to the underlying table that would violate the table’s constraints.
However, you can also define a view to restrict the user’s ability to change underlying table data
even further, effectively placing a special constraint for data manipulation through the view. This
additional constraint says that INSERT or UPDATE statements issued against the view are
cannot create rows that the view cannot subsequently select. This constraint is configured when
the view is defined by adding the WITH CHECK OPTION to the CREATE VIEW statement.
Incorrect Answers
A: This view does not provide correct semantic of question task.
B: WITH READ ONLY clause is incorrect syntax in the CREATE VIEW command.
D: This view does not provide correct semantic of question task.
E: NO UPDATE clause is incorrect syntax in the CREATE VIEW command.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 301-303
Chapter 7: Creating Other Database Objects in Oracle
Question: 187. (I)
Which two statements about views are true? (Choose two.)
A. A view can be created as read only.
B. A view can be created as a join on two or more tables.
C. A view cannot have an ORDER BY clause in the SELECT statement.
D. A view cannot be created with a GROUP BY clause in the SELECT statement.
E. A view must have aliases defined for the column names in the SELECT statement.
Answer: A & B
Explanation:
A view can be created as read only object. However, it is possible to change data in the
underlying table(s) with some restrictions.A view also can be created as a join on two or more
tables. This type of view is called complex view. Complex views provide complicated data models
where many base tables are drawn together into one virtual table.
Incorrect Answers
C: Query operations containing ORDER BY clause are also permitted, so long as the ORDER BY
clause appearsoutside the parentheses. The following is an example of what I mean: CREATE
VIEW my_view AS (SELECT*FROM emp) ORDER BYempno.
D: A view can be created with a GROUP BY clause in the SELECT statement.
E: It is not required to have aliases defined for the column names in the SELECT statement.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 292-309
Chapter 7: Creating Other Database Objects in Oracle
Question: 188.(J)
The database administrator of your company created a public synonym called HR for the
HUMAN_RESOURCES table of the GENERAL schema, because many users frequently use this
table.
As a user of the database, you created a table called HR in your schema. What happens when
you execute this query?
SELECT *
FROM HR;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 123 of 179
A. You obtain the results retrieved from the public synonym HR created by the database
administrator.
B. You obtain the results retrieved from the HR table that belongs to your schema.
C. You get an error message because you cannot retrieve from a table that has the same name
as a public synonym.
D. You obtain the results retrieved from both the public synonym HR and the HR table that
belongs to your schema, as a Cartesian product.
E. You obtain the results retrieved from both the public synonym HR and the HR table that
belongs to your schema, as a FULL JOIN.
Answer: B
Explanation:
By executing this query you will extract data from the HR table in your own schema, it will not
work with HR synonym for the HUMAN_RESOURCES table of the GENERAL schema.
Incorrect Answers
A: The results will be retrieved from the table in your own schema, not from the GENERAL
schema, using synonym HR.
C: There is no error: data from the table in your own schema will be retrieved by this query.
D: This query will not generate Cartesian product from both tables.
E: This query will not retrieve data from both tables as a FULL JOIN.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 331-335
Chapter 7: Creating Other Database Objects in Oracle
Question: 189. (J)
Examine the structure of the EMPLOYEES table:
Column name Data type Remarks
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
LAST_NAME VARCNAR2(30)
FIRST_NAME VARCNAR2(30)
JOB_ID NUMBER
SAL NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER
You need to create an index called NAME_IDX on the first name and last name fields of the
EMPLOYEES table. Which SQL statement would you use to perform this task?
A. CREATE INDEX NAME_IDX (first_name, last_name);
B. CREATE INDEX NAME_IDX (first_name AND last_name);
C. CREATE INDEX NAME_IDX
ON (first_name, last_name);
D. CREATE INDEX NAME_IDX
ON employees (first_name AND last_name);
E. CREATE INDEX NAME_IDX
ON employees(first_name, last_name);
F. CREATE INDEX NAME_IDX
FOR employees(first_name, last_name);
Answer: E
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 124 of 179
Index is a schema object. It is used by the oracle server to speed up the retrieval of rows by using
a pointer and can reduce disk I/O by using rapid path access method to locate the data quickly. It
is independent of the table it indexes. Indexes are created for column which contain a wide range
of values. It can be created on the first name and last name fields of the employees table using
command as
CREATE INDEX NAME_IDX
ON employees(first_name, last_name);
Question: 190. (J)
In which scenario would index be most useful?
A. The indexed column is declared as NOT NULL.
B. The indexed columns are used in the FROM clause.
C. The indexed columns are part of an expression.
D. The indexed column contains a wide range of values.
Answer: D
Explanation:
Index will be useful if the indexed column contains a wide range of values. Especially B-tree
indexes will work better for tables with a wide range of values. But for tables just with some
distinct values bitmap indexes will be more helpful.
Incorrect Answers
A: Oracle automatically creates index for NOT NULL columns, so you don’t need create an index
yourself.
B: There are only table names in the FROM clause, not columns.
C: Index may be will not work if the indexed columns are part of an expression. You need to
avoid expressions if you want to use index.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 322-331
Chapter 3: Creating Other Database Objects in Oracle
Question: 191. (J)
Mary has a view called EMP_DEPT_LOC_VU that was created based on the EMPLOYEES,
DEPARTMENTS, and LOCATIONS tables. She granted SELECT privilege to Scott on this view.
Which option enables Scott to eliminate the need to qualify the view with the name MARY
.EMP_DEP_LOC_VU each time the view is referenced?
A. Scott can create a synonym for the EMP_DEPT_LOC_VU bus using the command:
CREATE PRIVATE SYNONYM EDL_VU
FOR mary.EMP DEPT_LOC_VU;
then he can prefix the columns with this synonymn.
B. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command:
CREATE SYNONYM EDL_VU
FOR mary.EMP_DEPT_LOC_VU;
then he can prefix the columns with this synonym.
C. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command:
CREATE LOCAL SYNONYM EDL_VU
FOR mary.EMP DEPT_LOC_VU;
then he can prefix the columns with this synonym.
D. Scott can create a synonym for the EMP_DEPT_LOC_VU by using the command:
CREATE SYNONYM EDL_VU.
ON mary(EMP_DEPT_LOC_VU);
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 125 of 179
then he can prefix the columns with this synonym.
E. Scott cannot create a synonym because synonyms can be created only for tables.
F. Scott cannot create any synonym for Mary’s view. Mary should create a private
synonym for the view and grant SELECT privilege on that synonym to Scott.
Answer: B
Explanation:
Correct syntax to create a local synonym is CREATE SYNONYM synonym_name. With PUBLIC
keyword you can create public synonym.
Incorrect Answers
A: There is no PRIVATE keyword for the CREATE SYNONYM command.
C: There is no LOCAL keyword for the CREATE SYNONYM command.
D: This SQL statement shows incorrect syntax to create a synonym.
E: Synonyms can be created not only for tables but for other objects also.
F: Scott can create synonym for Mary’s view because she granted SELECT privilege to Scott on
this view.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 331-335
Chapter 7: Creating Other Database Objects in Oracle
Question: 192. (J)
Which two statements about sequences are true? (Choose two)
A. You use a NEXTVAL pseudo column to look at the next possible value that would be
generated from a sequence, without actually retrieving the value.
B. You use a CURRVAL pseudo column to look at the current value just generated from a
sequence, without affecting the further values to be generated from the sequence.
C. You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by
actually retrieving the value from the sequence.
D. You use a CURRVAL pseudo column to generate a value from a sequence that would be
used for a specified database column.
E. If a sequence starting from a value 100 and incremented by 1 is used by more then one
application, then all of these applications could have a value of 105 assigned to their column
whose value is being generated by the sequence.
F. You use REUSE clause when creating a sequence to restart the sequence once it generates
the maximum value defined for the sequence.
Answer: B & C
Explanation:
You use a CURRVAL pseudo column to look at the current value just generated from a
sequence, without affecting the further values to be generated from the sequence. You use a
NEXTVAL pseudo column to obtain the next possible value from a sequence by actually
retrieving the value from the sequence.
Incorrect Answers
A: You use a NEXTVAL pseudo column to obtain the next possible value from a sequence by
actually retrieving the value from the sequence.
D: You use a CURRVAL pseudo column to look at the current value just generated from a
sequence, without affecting the further values to be generated from the sequence.
E: This statement is not correct. There is no limitation like that in Oracle.
F: You use CYCLE clause, not REUSE, when creating a sequence to restart the sequence once
it generates the maximum value defined for the sequence.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 126 of 179
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 315-322
Chapter 7: Creating Other Database Objects in Oracle
Question: 193. (J)
Which SELECT statement will display the next value of the PARTS_ID_SEQ sequence by
actually retrieving the value from the sequence?
A. SELECT NEXTVAL(parts_id_seq)
FROM SYS.DUAL;
B. SELECT parts_id_seq.NEXTVAL
FROM inventory;
C. SELECT parts_id_seq.NEXTVAL
FROM SYS.DUAL;
D. SELECT NEXTVAL(parts_id_seq)
FROM inventory;
E. SELECT parts_id_seq NEXTVAL
FROM inventory;
Answer: C
Explanation:
To display the next value of the PARTS_ID_SEQ sequence you can use the following statement
SELECT parts_id_seq.NEXTVAL
FROM SYS.DUAL;
Question: 194. (J)
You issue this statement:
CREATE PUBLIC SYNONYM part
FOR linda.product;
Which task was accomplished by this statement?
A. A new segment object was created.
B. A new object privilege was assigned.
C. A new system privilege was assigned.
D. The need to qualify an object name with its schema was eliminated.
Answer: D
Explanation:
You can simply the access to the database object by using a synonym an new name for an
object. PUBLIC synonym is accessible to all the users of the database. After creating a synonym
the need to access an object with its schema was eliminated.
Question: 195. (J)
User Mark wants to eliminate the need to type the full table name when querying the
TRANSACTION_HISTORY table existing in her schema. All other database users should use the
schema and full table name when referencing this table.
Which statement should user Marilyn execute?
A. CREATE PUBLIC SYNONYM trans_hist
FOR mark;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 127 of 179
B. CREATE SYNONYM trans_hist
FOR transaction_history;
C. CREATE PRIVATE SYNONYM trans_hist
FOR mark.transaction_history;
D. CREATE PUBLIC trans_hist SYNONYM
FOR mark.transaction_history;
Answer: B
Explanation:
To create a synonym in your own schema use the command
CREATE SYNONYM trans_hist
FOR transaction_history;
Now use Mark can access a TRANSACTION_HISTORY table with an alternate name trans_list in
her schema.
Question: 196. (J)
The TEACHER table in your schema contains these columns:
ID NUMBER(9) NOT NULL, Primary Key
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
SUBJECT_ID NUMBER(9)
You execute this statement:
CREATE INDEX teacher_name_idx
ON teacher(first_name, last_name);
Which statement is true?
A. The statement creates a composite non-unique index.
B. The statement creates a composite unique index.
C. You must have the CREATE ANY INDEX privilege for the statement to succeed.
D. The statement will fail because it contains a syntax error.
Answer: A
Explanation:
Indexes can be unique or nonunique. Unique indexes guarantee that no two rows of a table have
duplicate values in the key column (or columns). Nonunique indexes do not impose this restriction
on the column values. By executing the above written statement a composite non unique index
will be created.
Question: 197. (J)
The LINE_ITEM table contains these columns:
LINE_ITEMID NUMBER(9)
ORDER_ID NUMBER(9)
PRODUCT_ID VARCHAR2(9)
QUANTITY NUMBER(5)
You created a sequence called LINE_ITEMID_SEQ to generate sequential values for the
LINE_ITEMID column.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 128 of 179
Evaluate this SELECT statement:
SELECT line_itemid_seq.CURRVAL
FROM dual;
Which task will this statement accomplish?
A. displays the next value of the LINE_ITEMID_SEQ sequence
B. displays the current value of the LINE_ITEMID_SEQ sequence
C. populates the LINE_ITEMID_SEQ sequence with the next value
D. increments the LINE_ITEMID column
Answer: B
Explanation:
CURRVAL is pesudocolumn that will display the current value of the sequence that has been
used.
Question: 198. (J)
Evaluate this statement:
CREATE SEQUENCE line_item_id_seq
START WITH 10001
MAXVALUE 999999999
NOCYCLE;
Which statement about this CREATE SEQUENCE statement is true?
A. The sequence will reuse numbers and will start with 10001.
B. The sequence will never reuse any numbers and will increment by 1.
C. The sequence will continue to generate values after it reaches its maximum value.
D. The CREATE SEQUENCE statement will cause a syntax error because an INCREMENT BY
value is not included.
Answer: B
Explanation:
When the sequence is created with out specifying the increment by clause then it will increase by
1 which is default value and NOCYCLE option state that the sequence will not used after
reaching its maximum value.
Question: 199. (J)
Which statement should you use to eliminate the need for all users to qualify Marilyn's
INVENTORY table with her schema when querying the table?
A. CREATE SYNONYM inventory
FOR inventory;
B. CREATE PUBLIC SYNONYM inventory
FOR marilyn;
C. CREATE PUBLIC SYNONYM inventory
FOR marilyn.inventory;
D. CREATE PUBLIC inventory SYNONYM
FOR marilyn.inventory;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 129 of 179
Answer: C
Explanation:
By creating a public synonym for the inventory table then the need to qualify the table with its
schema name is eliminated as it has been done by the following command.
CREATE PUBLIC SYNONYM inventory
FOR marilyn.inventory;
Question: 200. (J)
Which statement will user Barbara use to create a private synonym when referencing the
EMPLOYEE table existing in user Chan's schema?
A. CREATE SYNONYM emp
FOR chan.employee;
B. CREATE PUBLIC SYNONYM emp
FOR chan.barbara;
C. CREATE PRIVATE SYNONYM emp
FOR chan.employee;
D. CREATE PUBLIC emp SYNONYM
FOR chan.employee;
Answer: A
Explanation:
To create a private synonym for your own schema use the following command.
CREATE SYNONYM emp
FOR chan.employee;
Question: 201. (J)
Why would you NOT create an index on a column in the CLASS_SCHEDULE table?
A. to reduce disk I/O
B. to speed up row retrieval
C. to speed up queries if the table has less than 50 rows
D. to speed up queries that return less than 3 percent of the rows
E. to speed up queries that include a foreign key reference to the STUDENT table
Answer: C
Explanation:
Index are created on the large table to speed up the data retrieval or if the changes are perfomed
on the table and the column is used in the WHERE clause then on that column you should create
an index to speed up the DML operations. If the table is small then index should not be created
as this would slow the speed of queries execution.
Question: 202.(K)
Which data dictionary table should you query to view the object privileges granted to the user on
specific columns?
A. USER_TAB_PRIVS_MADE
B. USER_TAB_PRIVS
C. USER_COL_PRIVS_MADE
D. USER_COL_PRIVS
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 130 of 179
Answer: D
Explanation:
The USER_COL_PRIVS data dictionary view will show the object privileges granted to the user
on specific columns.
Incorrect Answers
A: There is no USER_TAB_PRIVS_MADE view in Oracle.
B: The USER_TAB_PRIVS data dictionary view is used to show the object privileges granted to
the user on the tables, not specific columns.
C: There is no USER_COL_PRIVS_MADE view in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-365
Chapter 8: User Access Control in Oracle
Question: 203. (K)
Which two statements accurately describe a role? (Choose two.)
A. A role can be given to a maximum of 1000 users.
B. A user can have access to a maximum of 10 roles.
C. A role can have a maximum of 100 privileges contained in it.
D. Privileges are given to a role by using the CREATE ROLE statement.
E. A role is a named group of related privileges that can be granted to the user.
F. A user can have access to several roles, and several users can be assigned the same role.
Answer: D & F
Explanation:
Privileges can be given to a role by using the CREATE ROLE statement. A user can have access
to several roles, and several users can be assigned the same role.
Incorrect Answers
A: There is no limitation to a 1000 users for one role in Oracle.
B: There is no limitation to a 10 roles for one user in Oracle.
C: There is no limitation to a 1000 privileges for one role in Oracle.
E: The role can act as a named group of privileges to execute certain tasks. But privileges can be
not related at all.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 365-373
Chapter 8: User Access Control in Oracle
Question: 204. (K)
Scott issues the SQL statements:
CREATE TABLE dept
(deptno NUMBER(2),
dname VARCHAR2(14),
loc VARCHAR2(13)};
GRANT SELECT
ON DEPT
TO SUE;
If Sue needs to select from Scott's DEPT table, which command should she use?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 131 of 179
A. SELECT *
FROM DEPT;
B. SELECT *
FROM SCOTT.DEPT;
C. SELECT *
FROM DBA.SCOTT.DEPT;
D. SELECT *
FROM ALL_ USERS
WHERE USER_NAME = 'SCOTT'
AND TABLE NAME = 'DEPT';
Answer: B
Explanation:
If the table doesn’t exist in your schema, you must prefix the table name with the schema
information, separating the owner from the table name with a period.
Incorrect Answers
A: If you don’t have DEPT table in your schema, this statement will fail.
C: This statement is incorrect.
D: This statement is incorrect. ALL_USERS view is used to extract information about users.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 28-29
Chapter 1: Overview of Oracle Databases
Question: 205. (K)
Which statement creates a new user?
A. CREATE USER susan;
B. CREATE OR REPLACE USER susan;
C. CREATE NEW USER susan
DEFAULT;
D. CREATE USER susan
IDENTIFIED BY blue;
E. CREATE NEW USER susan
IDENTIFIED by blue;
F. CREATE OR REPLACE USER susan
IDENTIFIED BY blue;
Answer: D
Explanation:
The correct statement to create user is: CREATE USER user_name IDENTIFIED BY password.
Incorrect Answers
A: This syntax is incorrect to create user: you need to provide also password for the user.
B: There is no CREATE OR REPLACE USER command in Oracle.
C: There is no CREATE NEW USER user_name DEFAULT command in Oracle.
E: There is no CREATE NEW USER user_name IDENTIFIED BY command in Oracle.
F: There is no CREATE OR REPLACE USER user_name IDENTIFIED BY command in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 348-351
Chapter 8: User Access in Oracle
Question: 206. (K)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 132 of 179
What is true about the WITH GRANT OPTION clause?
A. It allows a grantee DBA privileges.
B. It is required syntax for object privileges.
C. It allows privileges on specified columns of tables.
D. It is used to grand an object privilege on a foreign key column.
E. It allows the grantee to grand object privileges to other users and roles.
Answer: E
Explanation:
The GRANT command with the WITH GRANT OPTION clause allows the grantee to grant object
privileges to other users and roles.
Incorrect Answers
A: The WITH GRANT OPTION does not allow a grantee DBA privileges.
B: It is not required syntax for object privileges. It is optional clause of GRANT command.
C: GRANT command does not allows privileges on columns of tables.
D: It is not used to grant an object privilege on a foreign key column.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-365
Chapter 8: User Access in Oracle
Question: 207. (K)
You need to give the MANAGER role the ability to select from, insert into, and modify existing
rows in the STUDENT_GRADES table. Anyone given this MANAGER role should be able to pass
those privileges on to others.
Which statement accomplishes this?
A. GRANT select, insert, update
ON student_grades
TO manager;
B. GRANT select, insert, update
ON student_grades
TO ROLE manager;
C. GRANT select, insert, modify
ON student_grades
TO manager
WITH GRANT OPTION;
D. GRANT select, insert, update
ON student_grades.
TO manager
WITH GRANT OPTION;
E. GRANT select, insert, update
ON student_grades
TO ROLE manager
WITH GRANT OPTION;
F. F.GRANT select, insert, modify
ON student_grades
TO ROLE manager
WITH GRANT OPTION;
Answer: D
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 133 of 179
Explanation:
This answer provides correct syntax of GRANT command to give the MANAGER role all asked
privileges. Clause WITH GRANT OPTION will allow this role to pass those privileges on to others.
Incorrect Answers
A: This statement would be correct if it included WITH GRANT OPTION clause to allow this role
to pass those privileges on to others.
B: This statement uses incorrect clause TO ROLE.
C: There is no option with name MODIFY in the GRANT command.
E: This statement uses incorrect clause TO ROLE.
F: There is no option with name MODIFY in the GRANT command. And this statement also uses
incorrect clause TO ROLE.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 356-365
Chapter 8: User Access Control in Oracle
Question: 208. (K)
When should you create a role? (Choose two)
A. To simplify the process of creating new users using the CREATE USER xxx IDENTIFIED by
yyy statement.
B. To grant a group of relate privileges to a user.
C. When the number of people using the database is very high.
D. To simplify the process of granting and revoking privileges.
E. To simplify profile maintenance for a user who is constantly traveling.
Answer: C & D
Explanation:
You should use roles to grant a group of privileges to a user. You grant the appropriate privileges
to the role and after that grant this role to specific users. By granting to or revoking privileges from
the role you can simplify procedure of users privileges maintainance: you don’t need to
grant/revoke privileges to/from each user. It’s especially very helpful when you are experiencing a
high number of people using the database.
Incorrect Answers
A: Roles have nothing to do with simplifying the process of creating new users.
B: You can use roles to grant a group of privileges to a user, but they can be not related at all.
E: Roles have nothing to do with user who is constantly traveling.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 365-372
Chapter 8: User Control in Oracle
Question: 209. (K)
The DBA issues this SQL command:
CREATE USER scott
IDENTIFIES by tiger;
What privileges does the user Scott have at this point?
A. No privileges.
B. Only the SELECT privilege.
C. Only the CONNECT privilege.
D. All the privileges of a default user.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 134 of 179
Answer: A
Explanation:
There are no privileges for the user Scott at this point. They are not added themselves to the user
immediately after creation. The DBA needs to grant all privileges explicitly.
Incorrect Answers
B: There are no privileges for the user Scott at this point. SELECT privilege needs to be added to
the user Scott.
C: There are no privileges for the user Scott at this point. CONNECT privilege needs to be added
to the user Scott.
D: There is no default user in Oracle.
OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 348-351
Chapter 8: User Access in Oracle
Question: 210. (K)
You granted user Joe the INDEX and REFERENCES privileges on the INVENTORY table. Which
statement did you use?
A. GRANT ALL
ON inventory
TO joe;
B. GRANT ANY PRIVILEGE
ON inventory
TO joe;
C. GRANT INDEX AND REFERENCES
ON inventory
TO joe;
D. GRANT ALL WITH GRANT OPTION
ON inventory
TO joe;
Answer: A
Explanation:
To grant privileges to a used on specific table use the following command
GRANT ALL
ON inventory TO joe;
This command will grant all privilege on the inventory table to the user joe
Question: 211. (K)
Which condition would allow a user to grant SELECT privileges on the CUSTOMER table to
everyone using the PUBLIC keyword?
A. The user has SELECT privileges on the CUSTOMER table.
B. The user owns the CUSTOMER table.
C. The user has been granted the PUBLIC privilege.
D. The user has been granted the SELECT privilege with the PUBLIC OPTION.
Answer: B
Explanation:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 135 of 179
To grant SELECT privilege to all users in the database you can use the PUBLIC key word. This
will grant the privileges to all users in the database.
Question: 212. (K)
You issued this statement:
REVOKE REFERENCES
ON inventory
FROM joe
CASCADE CONSTRAINTS;
Which two tasks were accomplished by executing this statement? (Choose two.)
A. All the PRIMARY KEY constraints created by user Joe were removed.
B. All the FOREIGN KEY constraints on the INVENTORY table created by user Joe were
removed.
C. The ability to create a PRIMARY KEY constraint was revoked from user Joe.
D. The ability to create a FOREIGN KEY constraint on the INVENTORY table was revoked from
user Joe.
E. All the constraints created by user Joe were removed.
F. The ability to create any constraints was revoked from user Joe.
Answer: B & D
Explanation:
REVOKE REFERENCE command will revoke the ability to create a foreign key constraints on the
inventory table by use joe and also all created FOREIGN KEY constraints will be removed.
Question: 213. (K)
Which privilege is an object privilege?
A. INDEX
B. DROP USER
C. CREATE SESSION
D. BACKUP ANY TABLE
Answer: A
Explanation:
INDEX an object privilege, which is granted to a user on a table if the INDEX privilege is revoked
from a user that created an index on someone else's table, the index continues to exist after the
privilege is revoked.
Question: 214. (K)
You issued this statement:
GRANT UPDATE
ON inventory
TO joe
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 136 of 179
WITH GRANT OPTION;
Which task was accomplished?
A. Only a system privilege was granted to user Joe.
B. Only an object privilege was granted to user Joe.
C. User Joe was granted all privileges on the INVENTORY object.
D. Both an object privilege and a system privilege were granted to user Joe.
Answer: B
Explanation:
By executing the above command only the UPDATE object privileges will be granted to the user
joe and WITH GRANT OPTION state that the user can further grant privilege to other users.
Question: 215. (K)
Which statement is true concerning a new user that has only been granted the CREATE
SESSION privilege?
A. The user can create a table.
B. The user can alter their password.
C. The user can select from tables they have created.
D. The user can grant privileges on objects that they own.
Answer: B
Explanation:
When a user has been granted the CREATE SESSION privilege then user can change their
password after connecting to the database.
Question: 216. (K)
Evaluate this SQL script:
CREATE USER hr IDENTIFIED BY hr01;
CREATE ROLE hr_manager;
CREATE ROLE hr_clerk;
GRANT hr_clerk TO hr_manager;
CREATE ROLE hr_director;
GRANT hr_manager TO hr_director;
GRANT hr_director TO hr
/
How many roles will the HR user have access to?
A. 0
B. 1
C. 2
D. 3
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 137 of 179
Answer: D
Explanation:
In the above statmen three roles will be granted to the user HR. as the role hr_clerk is granted to
the hr_manager and then hr_manager is granted to the hr_director role and then this hr_director
role is granted to the user HR have access to all three roles.
Question: 217 (A)
Examine the structure of the EMP_DEPT_VU view:
Column Name Type Remarks
EMPLOYEE_ID NUMBER From the EMPLOYEES table
EMP_NAME VARCHAR2(30) From the EMPLOYEES table
JOB_ID VARCHAR2(20) From the EMPLOYEES table
SALARY NUMBER From the EMPLOYEES table
DEPARTMENT_ID NUMBER From the DEPARTMENTS table
DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table
Which SQL statement produces an error?
A. SELECT * FROM emp_dept_vu;
B. SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department_id;
C. SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY
department_id, job_id;
D. SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20)
GROUP BY job_id HAVING SUM(salary) > 20000;
E. None of the statements produce an error; all are valid.
Answer: E
Explanation :
None of the statements produce an error.
Incorrect answer :
A Statement will not cause error
B Statement will not cause error
C Statement will not cause error
D Statement will not cause error
Question: 218 (H)
You own a table called EMPLOYEES with this table structure:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
What happens when you execute this DELETE statement?
DELETE employees;
A. You get an error because of a primary key violation.
B. The data and structure of the EMPLOYEES table are deleted.
C. The data in the EMPLOYEES table is deleted but not the structure.
D. You get an error because the statement is not syntactically correct.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 138 of 179
Answer: C
Explanation :
You can remove existing rows from a table by using the DELETE statement.
DELETE [FROM] table
[WHERE condition];
Incorrect answer :
A Statement will not cause error
B Delete statement will not delete the table structure
D Statement will not cause error
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 8-19
Question: 219 (H)
Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
NEW_EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which MERGE statement is valid?
A. MERGE INTO new_employees c USING employees e ON (c.employee_id =
e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','||
e.last_name WHEN NOT MATCHED THEN INSERT VALUES (e.employee_id,
e.first_name ||', '||e.last_name);
B. MERGE new_employees c USING employees e ON (c.employee_id = e.employee_id)
WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT
MATCHED THEN INSERT VALUES (e.employee_id, e.first_name ||', '||e.last_name);
C. MERGE INTO new_employees c USING employees e ON (c.employee_id =
e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','||
e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id,
e.first_name ||', '||e.last_name);
D. MERGE new_employees c FROM employees e ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN
NOT MATCHED THEN INSERT INTO new_employees VALUES (e.employee_id,
e.first_name ||', '||e.last_name);
Answer: A
Explanation :
The correct statement for MERGE is
MERGE INTO table_name
Incorrect answer :
B Wrong statement with the keyword EXISTS
C Wrong statement with the keyword EXISTS
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 139 of 179
D Wrong statement on the MERGE new_employees
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 8-29
Question: 220 (C)
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(4)
ENAME VARCHAR2 (25)
JOB_ID VARCHAR2(10)
Which SQL statement will return the ENAME, length of the ENAME, and the numeric position of
the letter "a" in the ENAME column, for those employees whose ENAME ends with a the letter
"n"?
A. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, 'a') FROM EMPLOYEES
WHERE SUBSTR(ENAME, -1, 1) = 'n';
B. SELECT ENAME, LENGTH(ENAME), INSTR(ENAME, ,-1,1) FROM EMPLOYEES
WHERE SUBSTR(ENAME, -1, 1) = 'n';
C. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES
WHERE INSTR(ENAME, 1, 1) = 'n';
D. SELECT ENAME, LENGTH(ENAME), SUBSTR(ENAME, -1,1) FROM EMPLOYEES
WHERE INSTR(ENAME, -1, 1) = 'n';
Answer: A
Explanation :
INSTR is a character function return the numeric position of a named string.
INSTR(NAMED,’a’)
Incorrect answer :
B Did not return a numeric position for ‘a’.
C Did not return a numeric position for ‘a’.
D Did not return a numeric position for ‘a’.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 3-8
Question: 221 (G)
Which four are valid Oracle constraint types? (Choose four.)
A. CASCADE
B. UNIQUE
C. NONUNIQUE
D. CHECK
E. PRIMARY KEY
F. CONSTANT
G. NOT NULL
Answer: B, D, E, G
Explanation :
Oracle constraint type is Not Null, Check, Primary Key, Foreign Key and Unique
Incorrect answer:
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 140 of 179
A Is not Oracle constraint
C Is not Oracle constraint
F Is not Oracle constraint
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-3
Question: 222 (I)
Which SQL statement would you use to remove a view called EMP_DEPT_VU from your
schema?
A. DROP emp_dept_vu;
B. DELETE emp_dept_vu;
C. REMOVE emp_dept_vu;
D. DROP VIEW emp_dept_vu;
E. DELETE VIEW emp_dept_vu;
F. REMOVE VIEW emp_dept_vu;
Answer: D
Explanation :
DROP VIEW viewname;
Incorrect answer:
A Not a valid drop view statement
B Not a valid drop view statement
C Not a valid drop view statement
E Not a valid drop view statement
F Not a valid drop view statement
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 11-20
Question: 223 (C)
Examine the description of the EMPLOYEES table:
EMP_ID NUMBER(4) NOT NULL
LAST_NAME VARCHAR2(30) NOT NULL
FIRST_NAME VARCHAR2(30)
DEPT_ID NUMBER(2)
Which statement produces the number of different departments that have employees with last
name Smith?
A. SELECT COUNT(*) FROM employees WHERE last_name='Smith';
B. SELECT COUNT (dept_id) FROM employees WHERE last_name='Smith';
C. SELECT DISTINCT(COUNT(dept_id)) FROM employees WHERE last_name='Smith';
D. SELECT COUNT(DISTINCT dept_id) FROM employees WHERE last_name='Smith';
E. SELECT UNIQUE(dept_id) FROM employees WHERE last_name='Smith';
Answer: D
Question: 224 (I)
Top N analysis requires _____ and _____. (Choose two.)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 141 of 179
A. the use of rowed
B. a GROUP BY clause
C. an ORDER BY clause
D. only an inline view
E. an inline view and an outer query
Answer: C, E
Explanation :
The correct statement for Top-N Analysis
SELECT [coloumn_list], ROWNUM
FROM (SELECT [coloumn_list]
FROM table
ORDER BY Top-N_coloumn)
WHERE ROWNUM <= N;
Incorrect answer :
A ROWID is not require
B GROUP BY clause is not require
D Must have inline view and outer query.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 11-23
Question: 225 (G)
Which statement adds a constraint that ensures the CUSTOMER_NAME column of the
CUSTOMERS table holds a value?
A. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name
IS NOT NULL;
B. ALTER TABLE customers MODIFY CONSTRAINT cust_name_nn CHECK
customer_name IS NOT NULL;
C. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn
NOT NULL;
D. ALTER TABLE customers MODIFY customer_name CONSTRAINT cust_name_nn IS
NOT NULL;
E. ALTER TABLE customers MODIFY name CONSTRAINT cust_name_nn NOT NULL;
F. ALTER TABLE customers ADD CONSTRAINT cust_name_nn CHECK customer_name
NOT NULL;
Answer: C
Question: 226 (A)
Evaluate this SQL statement:
SELECT ename, sal, 12*sal+100 FROM emp;
The SAL column stores the monthly salary of the employee. Which change must be made to the
above syntax to calculate the annual compensation as "monthly salary plus a monthly bonus of
$100, multiplied by 12"?
A. No change is required to achieve the desired results.
B. SELECT ename, sal, 12*(sal+100) FROM emp;
C. SELECT ename, sal, (12*sal)+100 FROM emp;
D. SELECT ename, sal+100,*12 FROM emp;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 142 of 179
Answer: B
Explanation:
To achieve the result you must add 100 to sal before multiply with 12.
Select ename, sal, 12*(sal+100) from EMP;
Incorrect Answer:
A Multiplication and division has priority over addition and subtraction in Operator precedence.
C Give wrong results
D Wrong syntax
Refer:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 1-11
Question: 227 (K)
You are the DBA for an academic database. You need to create a role that allows a group of
users to modify existing rows in the STUDENT_GRADES table.
Which set of statements accomplishes this?
A. CREATE ROLE registrar; GRANT MODIFY ON student_grades TO registrar; GRANT
registrar to user1, user2, user3
B. CREATE NEW ROLE registrar; GRANT ALL ON student_grades TO registrar; GRANT
registrar to user1, user2, user3
C. CREATE ROLE registrar; GRANT UPDATE ON student_grades TO registrar; GRANT
ROLE registrar to user1, user2, user3
D. CREATE ROLE registrar; GRANT UPDATE ON student_grades TO registrar; GRANT
registrar to user1, user2, user3;
E. CREATE registrar; GRANT CHANGE ON student_grades TO registrar; GRANT
registrar;
Answer: D
Explanation:
This is the correct solution for the answer.
GRANT role_name to users;
Incorrect answer :
A there is no such MODIFY keyword
B invalid CREATE command, there is no such NEW keyword
C invalid GRANT command, there is no such ROLE keyword
E invalid GRANT command, there is no such CHANGE keyword
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 13-10
Question: 228 (G)
You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The
table is currently empty.
Which statement accomplishes this task?
A. ALTER TABLE students ADD PRIMARY KEY student_id;
B. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);
C. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;
D. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 143 of 179
E. ALTER TABLE studentsMODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);
Answer: D
Explanation :
ALTER TABLE table_name
ADD [CONSTRAINT constraint] type (coloumn);
Incorrect answer :
A wrong syntax
B wrong syntax
C wrong syntax
E no such MODIFY keyword
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-17
Question: 229 (B)
The STUDENT_GRADES table has these columns:
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
The registrar requested a report listing the students' grade point averages (GPA) sorted from
highest grade point average to lowest.
Which statement produces a report that displays the student ID and GPA in the sorted order
requested by the registrar?
A. SELECT student_id, gpa FROM student_grades ORDER BY gpa ASC;
B. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa ASC;
C. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa;
D. SELECT student_id, gpa FROM student_grades ORDER BY gpa;
E. SELECT student_id, gpa FROM student_grades SORT ORDER BY gpa DESC;
F. SELECT student_id, gpa FROM student_grades ORDER BY gpa DESC;
Answer: F
Explanation :
sorted by highest to lowest is DESCENDING order
Incorrect answer :
A result in ascending order
B wrong syntax with SORT keyword
C wrong syntax with SORT keyword
D default value for ORDER by is in ascending order
E wrong syntax with SORT keyword
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 2-22
Question: 230 (F)
Which describes the default behavior when you create a table?
A. The table is accessible to all users.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 144 of 179
B. Tables are created in the public schema.
C. Tables are created in your schema.
D. Tables are created in the DBA schema.
E. You must specify the schema when the table is created.
Answer: C
Explanation :
sorted by highest to lowest is DESCENDING order
Incorrect answer :
A grant the table privilege to PUBLIC
B login as sysoper
D login as DBA or sysdba
E no such option is allow.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 9-9
Question: 231 (C)
Which four are attributes of single row functions? (Choose four.)
A. cannot be nested
B. manipulate data items
C. act on each row returned
D. return one result per row
E. accept only one argument and return only one value
F. accept arguments which can be a column or an expression
Answer: B, C, D, F
Question: 232 (F)
You need to create a table named ORDERS that contain four columns:
1. an ORDER_ID column of number data type
2. a CUSTOMER_ID column of number data type
3. an ORDER_STATUS column that contains a character data type
4. a DATE_ORDERED column to contain the date the order was placed.
When a row is inserted into the table, if no value is provided when the order was placed, today’s
date should be used instead.
Which statement accomplishes this?
A. CREATE TABLE orders (
order_id NUMBER (10),
customer_id NUMBER (8),
order_status VARCHAR2 (10),
date_ordered DATE = SYSDATE);
B. CREATE TABLE orders (
order_id NUMBER (10),
customer_id NUMBER (8),
order_status VARCHAR2 (10),
date_ordered DATE DEFAULT SYSDATE);
C. CREATE OR REPLACE TABLE orders (
order_id NUMBER (10),
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 145 of 179
customer_id NUMBER (8),
order_status VARCHAR2 (10),
date_ordered DATE DEFAULT SYSDATE);
D. CREATE OR REPLACE TABLE orders (
order_id NUMBER (10),
customer_id NUMBER (8),
order_status VARCHAR2 (10),
date_ordered DATE = SYSDATE);
E. CREATE TABLE orders (
order_id NUMBER (10),
customer_id NUMBER (8),
order_status NUMBER (10),
date_ordered DATE = SYSDATE);
F. CREATE TABLE orders (
order_id NUMBER (10),
customer_id NUMBER (8),
order_status NUMBER (10),
date_ordered DATE DEFAULT SYSDATE);
Answer: B
Question: 233 (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
Which three statements insert a row into the table? (Choose three.)
A. INSERT INTO employees VALUES ( NULL, 'John', 'Smith');
B. INSERT INTO employees( first_name, last_name) VALUES( 'John', 'Smith');
C. INSERT INTO employees VALUES ( '1000', 'John', NULL);
D. INSERT INTO employees (first_name, last_name, employee_id) VALUES ( 1000, 'John',
'Smith');
E. INSERT INTO employees (employee_id) VALUES (1000);
F. INSERT INTO employees (employee_id, first_name, last_name) VALUES ( 1000, 'John', ' ');
Answer: C, E, F
Explanation :
EMPLOYEE_ID is a primary key.
Incorrect answer :
A EMPLOYEE_ID cannot be null
B EMPLOYEE_ID cannot be null
D mismatch of field_name with datatype
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-11
Question: 234 (K)
The user Sue issues this SQL statement:
GRANT SELECT ON sue.EMP TO alice WITH GRANT OPTION;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 146 of 179
The user Alice issues this SQL statement:
GRANT SELECT ON sue.EMP TO reena WITH GRANT OPTION;
The user Reena issues this SQL statement:
GRANT SELECT ON sue.EMP TO timber;
The user Sue issues this SQL statement:
REVOKE select on sue.EMP FROM alice;
For which users does the revoke command revoke SELECT privileges on the SUE.EMP table?
A. Alice only
B. Alice and Reena
C. Alice, Reena, and Timber
D. Sue, Alice, Reena, and Timber
Answer: C
Explanation :
use the REVOKE statement to revoke privileges granted to other users. Privilege granted to
others through the WITH GRANT OPTION clause are also revoked.
Alice, Reena and Timber will be revoke.
Incorrect answer :
A the correct answer should be Alice, Reena and Timber
B the correct answer should be Alice, Reena and Timber
D the correct answer should be Alice, Reena and Timber
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 13-17
Question: 235 (B)
The EMPLOYEES table contains these columns:
EMPLOYEE_ID NUMBER(4)
LAST_NAME VARCHAR2 (25)
JOB_ID VARCHAR2(10)
You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do
you use?
A. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA\_%'
ESCAPE '\';
B. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_';
C. SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_'
ESCAPE "\";
D. SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_';
Answer: A
Explanation:
ESCAPE identifier to search for the actual % and _ symbol
Incorrect answer :
B ESCAPE identifier must be use
C wrong syntax
D wrong syntax
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 147 of 179
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 2-13
Question: 236 (A)
The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
CUSTOMER_ADDRESS VARCHAR2(150)
CUSTOMER_PHONE VARCHAR2(20)
You need to produce output that states "Dear Customer customer_name, ". The customer_name
data values come from the CUSTOMER_NAME column in the CUSTOMERS table.
Which statement produces this output?
A. SELECT dear customer, customer_name, FROM customers;
B. SELECT "Dear Customer", customer_name || ',' FROM customers;
C. SELECT 'Dear Customer ' || customer_name ',' FROM customers;
D. SELECT 'Dear Customer ' || customer_name || ',' FROM customers;
E. SELECT "Dear Customer " || customer_name || "," FROM customers;
F. SELECT 'Dear Customer ' || customer_name || ',' || FROM customers;
Answer: D
Explanation :
Concatenation operator to create a resultant column that is a character expression.
Incorrect answer :
A no such dear customer column
B invalid syntax
C invalid syntax
E invalid syntax
F invalid syntax
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 1-18
Question: 237 (J)
What is true about sequences?
A. Once created, a sequence belongs to a specific schema.
B. Once created, a sequence is linked to a specific table.
C. Once created, a sequence is automatically available to all users.
D. Only the DBA can control which sequence is used by a certain table.
E. Once created, a sequence is automatically used in all INSERT and UPDATE statements.
Answer: A
Question: 238 (K)
Which object privileges can be granted on a view?
A. none
B. DELETE, INSERT,SELECT
C. ALTER, DELETE, INSERT, SELECT
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 148 of 179
D. DELETE, INSERT, SELECT, UPDATE
Answer: D
Explanation :
Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE.
Incorrect answer :
A Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE
B Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE
C Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 13-12
Question: 239 (F)
Examine the SQL statement that creates ORDERS table:
CREATE TABLE orders (SER_NO NUMBER UNIQUE, ORDER_ID NUMBER,
ORDER_DATE DATE NOT NULL, STATUS VARCHAR2(10) CHECK (status IN
('CREDIT', 'CASH')), PROD_ID NUMBER REFERENCES PRODUCTS(PRODUCT_ID),
ORD_TOTAL NUMBER, PRIMARY KEY (order_id, order_date));
For which columns would an index be automatically created when you execute the above SQL
statement? (Choose two.)
A. SER_NO
B. ORDER_ID
C. STATUS
D. PROD_ID
E. ORD_TOTAL
F. composite index on ORDER_ID and ORDER_DATE
Answer: A, F
Explanation:
Index exist for UNIQUE and PRIMARY KEY constraints
Incorrect answer :
B ORDER_ID is neither UNIQUE nor PRIMARY KEY
C STATUS is neither UNIQUE nor PRIMARY KEY
D PROD_ID is neither UNIQUE nor PRIMARY KEY
E ORD_TOTAL is neither UNIQUE nor PRIMARY KEY
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-15
Question: 240 (C)
What is true of using group functions on columns that contain NULL values?
A. Group functions on columns ignore NULL values.
B. Group functions on columns returning dates include NULL values.
C. Group functions on columns returning numbers include NULL values.
D. Group functions on columns cannot be accurately used on columns that contain NULL values.
E. Group functions on columns include NULL values in calculations if you use the keyword
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 149 of 179
INC_NULLS.
Answer: A
Explanation :
group functions on column ignore NULL values
Incorrect answer :
B group functions on column ignore NULL values
C group functions on column ignore NULL values
D NVL function can be use for column with NULL values
E no such INC_NULLS keyword
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 5-12
Question: 241 (C)
The STUDENT_GRADES table has these columns:
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
Which statement finds the highest grade point average (GPA) per semester?
A. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL;
B. SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL;
C. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY
semester_end;
D. SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM
student_grades;
E. SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT
NULL;
Answer: C
Explanation :
for highest gpa value MAX function is needed,
for result with per semester GROUP BY clause is needed
Incorrect answer :
A per semester condition is not included
B result would not display the highest gpa value
D invalid syntax error
E invalid syntax error
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 5-7
Question: 242 (E)
In which four clauses can a subquery be used? (Choose four.)
A. in the INTO clause of an INSERT statement
B. in the FROM clause of a SELECT statement
C. in the GROUP BY clause of a SELECT statement
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 150 of 179
D. in the WHERE clause of a SELECT statement
E. in the SET clause of an UPDATE statement
F. in the VALUES clause of an INSERT statement
Answer: B, D, E, F
Explanation :
subquery can be use in the FROM clause of a SELECT statement, in the WHERE clause of a
SELECT statement, in the SET clauses of an UPDATE statement, in the VALUES clause of an
INSERT statement.
Incorrect answer :
A subquery cannot be used
C subquery cannot be used
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 6-5
Question: 243 (H)
Examine this statement:
SELECT student_id, gpa FROM student_grades WHERE gpa > &&value;
You run the statement once, and when prompted you enter a value of 2.0. A report is produced.
What happens when you run the statement a second time?
A. An error is returned.
B. You are prompted to enter a new value.
C. A report is produced that matches the first report produced.
D. You are asked whether you want a new value or if you want to run the report based on the
previous value.
Answer: C
Explanation :
use the double-ampersand if you want to reuse the variable value without prompting the user
each time.
Incorrect answer :
A is not an error
B && will not prompt user for second time
D && will not ask the user for new value
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 7-13
Question: 244 (C)
Which SQL statement returns a numeric value?
A. SELECT ADD_MONTHS(MAX(hire_Date), 6) FROM EMP;
B. SELECT ROUND(hire_date)FROM EMP;
C. SELECT sysdate-hire_date FROM EMP;
D. SELECT TO_NUMBER(hire_date + 7)FROM EMP;
Answer: C
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 151 of 179
Explanation :
DATE value subtract DATE value will return numeric value.
Incorrect answer :
A does not return numeric value
B does not return numeric value
D does not return numeric value
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 9-13
Question: 245 (J)
What are two reasons to create synonyms? (Choose two.)
A. You have too many tables.
B. Your tables are too long.
C. Your tables have difficult names.
D. You want to work on your own tables.
E. You want to use another schema's tables.
F. You have too many columns in your tables.
Answer: C, E
Question: 246 (I)
What is true about updates through a view?
A. You cannot update a view with group functions.
B. When you update a view group functions are automatically computed.
C. When you update a view only the constraints on the underlying table will be in effect.
D. When you update a view the constraints on the views always override the constraints on the
underlying tables.
Answer: A
Question: 247 (E)
You need to write a SQL statement that returns employee name, salary, department ID, and
maximum salary earned in the department of the employee for all employees who earn less than
the maximum salary in their department.
Which statement accomplishes this task?
A. SELECT a.emp_name, a.sal, b.dept_id, MAX(sal) FROM employees a, departments b
WHERE a.dept_id = b.dept_id AND a.sal < MAX(sal) GROUP BY b.dept_id;
B. SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a, (SELECT dept_id,
MAX(sal) maxsal FROM employees GROUP BY dept_id) b WHERE a.dept_id = b.dept_id
AND a.sal < b.maxsal;
C. SELECT a.emp_name, a.sal, a.dept_id, b.maxsal FROM employees a WHERE a.sal <
(SELECT MAX(sal) maxsal FROM employees b GROUP BY dept_id);
D. SELECT emp_name, sal, dept_id, maxsal FROM employees, (SELECT dept_id,
MAX(sal) maxsal FROM employees GROUP BY dept_id) WHERE a.sal < maxsal;
Answer: B
Explanation :
function MAX(column_name)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 152 of 179
Incorrect answer :
A invalid statement
C inner query return more than one line
D column maxsal does not exists.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 5-7
Question: 248 (B)
The CUSTOMERS table has these columns:
CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
STREET_ADDRESS VARCHAR2(150)
CITY_ADDRESS VARCHAR2(50)
STATE_ADDRESS VARCHAR2(50)
PROVINCE_ADDRESS VARCHAR2(50)
COUNTRY_ADDRESS VARCHAR2(50)
POSTAL_CODE VARCHAR2(12)
CUSTOMER_PHONE VARCHAR2(20)
A promotional sale is being advertised to the customers in France. Which WHERE clause
identifies customers that are located in France?
A. WHERE lower(country_address) = "france"
B. WHERE lower(country_address) = 'france'
C. WHERE lower(country_address) IS 'france'
D. WHERE lower(country_address) = '%france%'
E. WHERE lower(country_address) LIKE %france%
Answer: B
Explanation :
WHERE lower(country_address)=’france’
Incorrect answer :
A invalid use of symbol “”
C invalid use of IS keyword
D invalid use of % in condition
E invalid use of condition
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 2-12
Question: 249 (H)
Which are iSQL*Plus commands? (Choose all that apply.)
A. INSERT
B. UPDATE
C. SELECT
D. DESCRIBE
E. DELETE
F. RENAME
Answer: D
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 153 of 179
Explanation :
The only SQL*Plus command in this list : DESCRIBE. It cannot be used as SQL command.
This command returns a description of tablename, including all columns in that table, the
datatype for each column and an indication of whether the column permits storage of NULL
values.
Incorrect answer:
A INSERT is not a SQL*PLUS command
B UPDATE is not a SQL*PLUS command
C SELECT is not a SQL*PLUS command
E DELETE is not a SQL*PLUS command
F RENAME is not a SQL*PLUS command
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 7
Question: 250 (C)
Examine the description of the CUSTOMERS table:
CUSTOMER_ID NUMBER(4) NOT NULL
CUSTOMER_NAME VARCHAR2(100) NOT NULL
STREET_ADDRESS VARCHAR2(150)
CITY_ADDRESS VARCHAR2(50)
STATE_ADDRESS VARCHAR2(50)
PROVINCE_ADDRESS VARCHAR2(50)
COUNTRY_ADDRESS VARCHAR2(50)
POSTAL_CODE VARCHAR2(12)
CUSTOMER_PHONE VARCHAR2(20)
The CUSTOMER_ID column is the primary key for the table.
Which statement returns the city address and the number of customers in the cities Los Angeles
or San Francisco?
A. SELECT city_address, COUNT(*)
FROM customers
WHERE city_address IN ( ‘Los Angeles’, ‘San Fransisco’);
B. SELECT city_address, COUNT (*)
FROM customers
WHERE city address IN ( ‘Los Angeles’, ‘San Fransisco’)
GROUP BY city_address;
C. SELECT city_address, COUNT(customer_id)
FROM customers
WHERE city_address IN ( ‘Los Angeles’, ‘San Fransisco’)
GROUP BY city_address, customer_id;
D. SELECT city_address, COUNT (customer_id)
FROM customers
GROUP BY city_address IN ( ‘Los Angeles’, ‘San Fransisco’);
Answer: B
Question: 251 (I)
What does the FORCE option for creating a view do?
A. creates a view with constraints
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 154 of 179
B. creates a view even if the underlying parent table has constraints
C. creates a view in another schema even if you don't have privileges
D. creates a view regardless of whether or not the base tables exist
Answer: D
Explanation :
create a view regardless of whether or not the base tables exist.
Incorrect answer :
A the option is not valid
B the option is not valid
C the option is not valid
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 11-3
Question: 252 (H)
A data manipulation language statement _____.
A. completes a transaction on a table
B. modifies the structure and data in a table
C. modifies the data but not the structure of a table
D. modifies the structure but not the data of a table
Answer: C
Explanation :
modifies the data but not the structure of a table
Incorrect answer :
A DML does not complete a transaction
B DDL modifies the structure and data in the table
D DML does not modified table structure.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 8-3
Question: 253 (C)
You need to perform these tasks:
1. Create and assign a MANAGER role to Blake and Clark
2. Grant CREATE TABLE and CREATE VIEW privileges to Blake and Clark
Which set of SQL statements achieves the desired results?
A. CREATE ROLE manager;
GRANT create table, create view
TO manager;
GRANT manager TO BLAKE,CLARK;
B. CREATE ROLE manager;
GRANT create table, create voew
TO manager;
GRANT manager ROLE TO BLAKE,CLARK;
C. GRANT manager ROLE TO BLAKE,CLARK;
GRANT create table, create voew
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 155 of 179
TO BLAKE CLARK;
***MISSING***
Answer: A
Question: 254 (K)
The DBA issues this SQL command:
CREATE USER scott IDENTIFIED by tiger;
What privileges does the user Scott have at this point?
A. no privileges
B. only the SELECT privilege
C. only the CONNECT privilege
D. all the privileges of a default user
Answer: A
Explanation :
when a user is created, by default no privilege is granted
Incorrect answer :
B SELECT is not grant
C CONNECT is not grant
D default profile is grant by default not privilege.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 13-6
Question: 255 (E)
Exhibit:
Examine the data in the EMPLOYEES table.
Examine the subquery:
SELECT last_name
FROM employees
WHERE salary IN (SELECT MAX(salary)
FROM employees
GROUP BY department_id);
Which statement is true?
A. The SELECT statement is syntactically accurate.
B. The SELECT statement does not work because there is no HAVING clause.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 156 of 179
C. The SELECT statement does not work because the column specified in the GROUP BY
clause is not in the SELECT list.
D. The SELECT statement does not work because the GROUP BY clause should be in the main
query and not in the subquery.
Answer: A
Question: 256 (K)
Examine the statement:
GRANT select, insert, update
ON student_grades
TO manager
WITH GRANT OPTION;
Which two are true? (Choose two.)
A. MANAGER must be a role.
B. It allows the MANAGER to pass the specified privileges on to other users.
C. It allows the MANAGER to create tables that refer to the STUDENT_GRADES table.
D. It allows the MANAGER to apply all DML statements on the STUDENT_GRADES table.
E. It allows the MANAGER the ability to select from, insert into, and update the
STUDENT_GRADES table.
F. It allows the MANAGER the ability to select from, delete from, and update the
STUDENT_GRADES table.
Answer: B, E
Explanation :
GRANT ROLE to ROLE/USER
Incorrect answer :
A Role can be grant to user
C Create table privilege is not granted
D Execute privilege is not granted
F Delete privilege is not granted
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 13-15
Question: 257 (I)
Which best describes an inline view?
A. a schema object
B. a subquery that can contain an ORDER BY clause
C. another name for a view that contains group functions
D. a subquery that is part of the FROM clause of another query
Answer: D
Explanation :
a subquery that is part of the FROM clause of another query
Incorrect answer :
A is not a schema object
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 157 of 179
B subquery can contain GROUP BY clause as well.
C does not necessary contains group functions
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 11-21
Question: 258 (D)
Examine the structure of the EMPLOYEES and DEPARTMENTS tables:
EMPLOYEES
EMPLOYEE_ID NUMBER
DEPARTMENT_ID NUMBER
MANAGER_ID NUMBER
LAST_NAME VARCHAR2(25)
DEPARTMENTS
DEPARTMENT_ID NUMBER
MANAGER_ID NUMBER
DEPARTMENT_NAME VARCHAR2(35)
LOCATION_ID NUMBER
You want to create a report displaying employee last names, department names, and locations.
Which query should you use to create an equi-join?
A. SELECT last_name, department_name, location_id FROM employees , departments ;
B. SELECT employees.last_name, departments.department_name, departments.location_id
FROM employees e, departments D WHERE e.department_id =d.department_id;
C. SELECT e.last_name, d.department_name, d.location_id FROM employees e, departments D
WHERE manager_id =manager_id;
D. SELECT e.last_name, d.department_name, d.location_id FROM employees e, departments D
WHERE e.department_id =d.department_id;
Answer: D
Explanation :
Equijoins are also called simple joins or inner joins. Equijoin involve primary key and foreign key.
Incorrect answer:
A there is no join
B invalid syntax
C does not involve the join in the primary and foreign key
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 4-8
Question: 259 (B)
The PRODUCTS table has these columns:
PRODUCT_ID NUMBER(4)
PRODUCT_NAME VARCHAR2(45)
PRICE NUMBER(8,2)
Evaluate this SQL statement:
SELECT * FROM PRODUCTS ORDER BY price, product_name;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 158 of 179
What is true about the SQL statement?
A. The results are not sorted.
B. The results are sorted numerically.
C. The results are sorted alphabetically.
D. The results are sorted numerically and then alphabetically.
Answer: D
Explanation :
the result is sort by price which is numeric and follow by product_name which is alphabetically.
Incorrect answer :
A the results are sorted
B the results are sorted with alphabetically as well
C the results are sorted with numerically as well
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 2-2
Question: 260 (D)
In which two cases would you use an outer join? (Choose two.)
A. The tables being joined have NOT NULL columns.
B. The tables being joined have only matched data.
C. The columns being joined have NULL values.
D. The tables being joined have only unmatched data.
E. The tables being joined have both matched and unmatched data.
F. Only when the tables have a primary key/foreign key relationship.
Answer: C, E
Explanation:
You use an outer join to also see rows that do not meet the join condition.
Incorrect answer :
A meet a join condition
B meet a join condition
D meet non join condition only
F does not take into consideration of primary key and foreign key relationship
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 4-17
Question: 261 (G)
Which constraint can be defined only at the column level?
A. UNIQUE
B. NOT NULL
C. CHECK
D. PRIMARY KEY
E. FOREIGN KEY
Answer: B
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 159 of 179
Explanation:
the NOT NULL constraint can be specified only at the column level, not at the table level.
Incorrect answer:
A UNIQUE can be define at table level
C CHECK can be define at table level
D PRIMARY KEY can be define at table level
E FOREIGN KEY can be define at table level
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-8
Question: 262 (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL
EMP_NAME VARCHAR2(30)
JOB_ID VARCHAR2(20)
SAL NUMBER
MGR_ID NUMBER
DEPARTMENT_ID NUMBER
You want to create a SQL script file that contains an INSERT statement. When the script is run,
the INSERT statement should insert a row with the specified values into the EMPLOYEES table.
The INSERT statement should pass values to the table columns as specified below:
EMPLOYEE_ID: Next value from the sequence
EMP_ID_SEQEMP_NAME and JOB_ID: As specified by the user during run time, through
substitution variables
SAL: 2000
MGR_ID: No value
DEPARTMENT_ID: Supplied by the user during run time through
substitution variable. The INSERT statement
should fail if the user supplies a value other than
20 or 50.
Which INSERT statement meets the above requirements?
A. INSERT INTO employeesVALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,
&did);
B. INSERT INTO employeesVALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,
&did IN (20,50));
C. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50)) VALUES
(emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did);
D. INSERT INTO (SELECT * FROM employees WHERE department_id IN (20,50) WITH CHECK
OPTION)VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL, &did);
E. INSERT INTO (SELECT * FROM employees WHERE (department_id = 20 AND
department_id = 50) WITH CHECK OPTION )VALUES (emp_id_seq.NEXTVAL, '&ename',
'&jobid', 2000, NULL, &did);
Answer: D
Question: 263 (K)
The user Alice wants to grant all users query privileges on her DEPT table. Which SQL statement
accomplishes this?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 160 of 179
A. GRANT select ON dept TO ALL_USERS;
B. GRANT select ON dept TO ALL;
C. GRANT QUERY ON dept TO ALL_USERS
D. GRANT select ON dept TO PUBLIC;
Answer: D
Explanation :
view the columns associated with the constraint names in the
USER_CONS_COLUMNS view.
Incorrect answer :
A table to view all constraints definition and names
B show all object name belong to user
C does not display column associated
E no such view
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-25
Question: 264 (G)
Which view should a user query to display the columns associated with the constraints on a table
owned by the user?
A. USER_CONSTRAINTS
B. USER_OBJECTS
C. ALL_CONSTRAINTS
D. USER_CONS_COLUMNS
E. USER_COLUMNS
Answer: D
Explanation :
view the columns associated with the constraint names in the
USER_CONS_COLUMNS view.
Incorrect answer :
A table to view all constraints definition and names
B show all object name belong to user
C does not display column associated
E no such view
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-25
Question: 265 (K)
Examine these statements:
CREATE ROLE registrar;
GRANT UPDATE ON student_grades TO registrar; GRANT
registrar to user1, user2, user3;
What does this set of SQL statements do?
A. The set of statements contains an error and does not work.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 161 of 179
B. It creates a role called REGISTRAR, adds the MODIFY privilege on the STUDENT_GRADES
object to the role, and gives the REGISTRAR role to three users.
C. It creates a role called REGISTRAR, adds the UPDATE privilege on the STUDENT_GRADES
object to the role, and gives the REGISTRAR role to three users.
D. It creates a role called REGISTRAR, adds the UPDATE privilege on the STUDENT_GRADES
object to the role, and creates three users with the role.
E. It creates a role called REGISTRAR, adds the UPDATE privilege on three users, and gives the
REGISTRAR role to the STUDENT_GRADES object.
F. It creates a role called STUDENT_GRADES, adds the UPDATE privilege on three users, and
gives the UPDATE role to the registrar.
Answer: C
Explanation:
the statement will create a role call REGISTRAR, grant UPDATE on student_grades to registrar,
grant the role to user1,user2 and user3.
Incorrect answer :
A the statement does not contain error
B there is no MODIFY privilege
D statement does not create 3 users with the role
E privilege is grant to role then grant to user
F privilege is grant to role then grant to user
Question: 266 (E)
Which two statements about subqueries are true? (Choose two.)
A. A subquery should retrieve only one row.
B. A subquery can retrieve zero or more rows.
C. A subquery can be used only in SQL query statements.
D. Subqueries CANNOT be nested by more than two levels.
E. A subquery CANNOT be used in an SQL query statement that uses group functions.
F. When a subquery is used with an inequality comparison operator in the outer SQL statement,
the column list in the SELECT clause of the subquery should contain only one column.
Answer: B, F
Explanation:
subquery can retrieve zero or more rows, subquery is used with an inequality camparison
operator in the outer SQL statement, the column list in the SELECT clause of the subquery
should contain only one column.
Incorrect answer :
A subquery can retrieve zero or more rows
C subquery is not SQL query statement
D subquery can be nested
E group function can be use with subquery
Question: 267 (G)
You need to design a student registration database that contains several tables storing academic
information. The STUDENTS table stores information about a student. The STUDENT_GRADES
table stores information about the student's grades. Both of the tables have a column named
STUDENT_ID. The STUDENT_ID column in the STUDENTS table is a primary key. You need to
create a foreign key on the STUDENT_ID column of the STUDENT_GRADES table that points to
the STUDENT_ID column of the STUDENTS table. Which statement creates the foreign key?
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 162 of 179
A. CREATE TABLE student_grades (student_id NUMBER(12),semester_end DATE, gpa
NUMBER(4,3), CONSTRAINT student_id_fk REFERENCES (student_id) FOREIGN KEY
students(student_id));
B. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa
NUMBER(4,3), student_id_fk FOREIGN KEY (student_id) REFERENCES
students(student_id));
C. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa
NUMBER(4,3), CONSTRAINT FOREIGN KEY (student_id) REFERENCES
students(student_id));
D. CREATE TABLE student_grades(student_id NUMBER(12),semester_end DATE, gpa
NUMBER(4,3), CONSTRAINT student_id_fk FOREIGN KEY (student_id) REFERENCES
students(student_id));
Answer: D
Explanation :
CONSTRAINT name FOREIGN KEY (column_name) REFERENCES table_name
(column_name);
Incorrect answer :
A invalid syntax
B invalid syntax
C invalid syntax
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 10-14
Question: 268 (H)
Evaluate the SQL statement:
TRUNCATE TABLE DEPT;
Which three are true about the SQL statement? (Choose three.)
A. It releases the storage space used by the table.
B. It does not release the storage space used by the table.
C. You can roll back the deletion of rows after the statement executes.
D. You can NOT roll back the deletion of rows after the statement executes.
E. An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement executes will
display an error.
F. You must be the owner of the table or have DELETE ANY TABLE system privileges to truncate
the DEPT table
Answer: A, D, F
Question: 269 (G)
Which two statements are true about constraints? (Choose two.)
A. The UNIQUE constraint does not permit a null value for the column.
B. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints.
C. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index.
D. The NOT NULL constraint ensures that null values are not permitted for the column.
Answer: B, D
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 163 of 179
Question: 270 (H)
Which three are true? (Choose three.)
A. A MERGE statement is used to merge the data of one table with data from another.
B. A MERGE statement replaces the data of one table with that of another.
C. A MERGE statement can be used to insert new rows into a table.
D. A MERGE statement can be used to update existing rows in a table.
Answer: A, B, C
Explanation:
Merge is used to merge the data of one table with data from another, replaces the data of one
table with that of another, used to insert new rows into a table.
Incorrect answer :
D MERGE statement can be used to update existing rows in a table if the condition match
Question: 271 (F)
Which is a valid CREATE TABLE statement?
A. CREATE TABLE EMP9$# AS (empid number(2));
B. CREATE TABLE EMP*123 AS (empid number(2));
C. CREATE TABLE PACKAGE AS (packid number(2));
D. CREATE TABLE 1EMP_TEST AS (empid number(2));
Answer: A
Explanation :
Table names and column names must begin with a letter and be 1-30 characters long.
Characters A-Z,a-z, 0-9, _, $ and # (legal characters but their use is discouraged).
Incorrect answer :
B. Non alphanumeric character such as “*” is discourage in Oracle table name.
D. Table name must begin with a letter.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 9-4
Question: 272 (A)
A SELECT statement can be used to perform these three functions:
- Choose rows from a table.
- Choose columns from a table.
- Bring together data that is stored in different tables by creating a link between them.
Which set of keywords describes these capabilities?
A. difference, projection, join
B. selection, projection, join
C. selection, intersection, join
D. intersection, projection, join
E. difference, projection, product
Answer: B
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 164 of 179
Explanation:
choose rows from a table is SELECTION,
Choose column from a table is PROJECTION Bring together data in different table by creating a
link between them is JOIN.
Incorrect answer :
A answer should have SELECTION, PROJECTION and JOIN.
C answer should have SELECTION, PROJECTION and JOIN.
D answer should have SELECTION, PROJECTION and JOIN.
E answer should have SELECTION, PROJECTION and JOIN.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 1-6
Question: 273 (C)
Which four are types of functions available in SQL? (Choose 4)
A. string
B. character
C. integer
D. calendar
E. numeric
F. translation
G. date
H. conversion
Answer: B, E, G, H
Explanation :
SQL have character, numeric, date, conversion function.
Incorrect answer :
A SQL have character, numeric, date, conversion function.
C SQL have character, numeric, date, conversion function.
D SQL have character, numeric, date, conversion function.
F SQL have character, numeric, date, conversion function.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 3-3
Question: 274 (J)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER NOT NULL, Primary Key
EMP_NAME VARCHAR2(30)
JOB_ID NUMBER
SAL NUMBER
MGR_ID NUMBER References EMPLOYEE_ID column
DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the
DEPARTMENTS table
You created a sequence called EMP_ID_SEQ in order to populate sequential values for the
EMPLOYEE_ID column of the EMPLOYEES table. Which two statements regarding the
EMP_ID_SEQ sequence are true? (Choose two.)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 165 of 179
A. You cannot use the EMP_ID_SEQ sequence to populate the JOB_ID column.
B. The EMP_ID_SEQ sequence is invalidated when you modify the EMPLOYEE_ID column.
C. The EMP_ID_SEQ sequence is not affected by modifications to the EMPLOYEES table.
D. Any other column of NUMBER data type in your schema can use the EMP_ID_SEQ
sequence.
E. The EMP_ID_SEQ sequence is dropped automatically when you drop the EMPLOYEES table.
F. The EMP_ID_SEQ sequence is dropped automatically when you drop the EMPLOYEE_ID
column.
Answer: C, D
Explanation :
the EMP_ID_SEQ sequence is not affected by modification to the EMPLOYEES table. Any other
column of NUMBER data type in your schema can use the EMP_ID_SEQ sequence.
Incorrect answer :
A EMP_ID_SEQ sequence can be use to populate JOB_ID
B EMP_ID_SEQ sequence will not be invalidate when column in EMPLOYEE_ID is modify.
E EMP_ID_SEQ sequence will be dropped automatically when you drop the EMPLOYEES table.
F EMP_ID_SEQ sequence will be dropped automatically when you drop the EMPLOYEE_ID
column.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 12-4
Question: 275 (B)
Evaluate these two SQL statements:
SELECT last_name, salary, hire_dateFROM EMPLOYEES ORDER BY salary DESC;
SELECT last_name, salary, hire_dateFROM EMPLOYEES ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending order by
default.
D. The two statements can be made to produce identical results by adding a column alias for the
salary column in the second SQL statement.
Answer: A
Explanation :
the two statement produce identical results as ORDER BY 2 will take the second column as
sorting column.
Incorrect answer :
B there is no syntax error
C result are sorted in ascending order by default
D ORDER BY 2 will take the second column as sorting column.
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 2-22
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 166 of 179
Question: 276 (H)
Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
NEW_EMPLOYEES
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which MERGE statement is valid?
A. MERGE INTO new_employees c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET
C.name = e.first_name ||','|| e.last_name
WHEN NOT MATCHED THEN
INSERT
value
S(e.employee_id, e.first_name ||',
'||e.last_name);
B. MERGE new_employees c
USING employees e
ON (c.employee_id = e.employee_id)
WHEN EXISTS THEN
UPDATE SET
C.name = e.first_name ||','|| e.last_name
WHEN NOT MATCHED THEN INSERT
valueS(e.employee_id, e.first_name ||',
'||e.last_name);
C. MERGE INTO new_employees cUSING employees e
ON (c.employee_id = e.employee_id)
WHEN EXISTS THEN
UPDATE SET
C.name = e.first_name ||','|| e.last_name
WHEN NOT MATCHED THEN
INSERT
value
S(e.employee_id, e.first_name ||',
'||e.last_name);
D. MERGE new_employees c
FROM employees e ON (c.employee_id = e.employee_id)
WHEN MATCHED THEN
UPDATE SET
c.name = e.first_name ||','|| e.last_name
WHEN NOT MATCHED THEN
INSERT INTO
new_employees valueS(e.employee_id, e.first_name ||',
'||e.last_name);
Answer: A
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 167 of 179
Explanation :
this is the correct MERGE statement syntax
Incorrect answer :
B it should MERGE INTO table_name
C it should be WHEN MATCHED THEN
D it should MERGE INTO table_name
Reference:
Introduction to Oracle9i : SQL, Oracle University Study Guide, 8-29
Question: 277 (C)
Which SQL statement displays the date March 19, 2001 in a format that appears as “Nineteenth
of March 2001 12:00:00 AM”?
A. SELECT
TO_CHAR(TO_DATE(“19-Mar-2001’, ‘DD-Mon-YYYY’), ‘fmDdspth
“of” Month YYYY fmHH:MI:SS AM’) NEW_DATE
FROM dual;
B. SELECT
TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY’), ‘Ddspth
“of” Month YYYY fmHH:MI:SS AM’) NEW_DATE
FROM dual;
C. SELECT
TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY’), ‘fmDdspth “of” Month
YYYY
HH:MI:SS AM’) NEW_DATE
D. SELECT
TO_CHAR(TO_DATE(’19-Mar-2001’, ‘DD-Mon-YYYY), ‘fmDdspth “of” Month
YYYYfmtHH:HI:SS AM') NEW_DATE FROM dual;
Answer: A
Question: 278 (K)
Which one is a system privilege?
A. SELECT
B. DELETE
C. EXECUTE
D. ALTER TABLE
E. CREATE TABLE
Answer: E
Question: 279 (A)
Which statement correctly describes SQL and /SQL*Plus?
A. Both SQL and /SQL*plus allow manipulation of values in the database.
B. /SQL*Plus recognizes SQL statements and sends them to the server; SQL is the Oracle
proprietary interface for executing SQL statements.
C. /SQL*Plus is a language for communicating with the Oracle server to access data; SQL
recognizes SQL statements and sends them to the server.
D. SQL manipulates data and table definitions in the database; /SQL*Plus does not allow
manipulation of values in the database.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 168 of 179
Answer: A
Question: 280 (D)
Exhibit
Examine the data in the EMPLOYEES and DEPARTMENTS tables.
You want to retrieve all employees’ last names, along with their manager’s last names and their
department names. Which query would you use?
A. SELECT last_name, manager_id, department_name
FROM employees e
FULL OUTER JOIN departments d ON (e.department_id = d.department_id);
B. SELECT e.last_name, m.last_name, department_name
FROM employees e
LEFT OUTER JOIN employees m on ( e.managaer_id = m.employee_id)
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
C. SELECT e.last_name, m.last_name, department_name
FROM employees e
RIGT OUTER JOIN employees m on ( e.manager_id = m.employee_id)
LEFT OUTER JOIN departments d ON (e.department_id = d.department_id);
D. SELECT e.last_name, m.last_name, department_name
FROM employees e
LEFT OUTER JOIN employees m on ( e.manager_id = m.employee_id)
RIGT OUTER JOIN departments d ON (e.department_id = d.department_id);
E. SELECT e.last_name, m.last_name, department_name
FROM employees e
RIGHT OUTER JOIN employees m on ( e.manager_id = m.employee_id)
RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id)
F. SELECT last_name, manager_id, department_name
FROM employees e
JOIN departments d ON (e.department_id = d.department_id) ;
Answer: B
Question: 281 (H)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 169 of 179
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
Which INSERT statement is valid?
A. INSERT INTO employees (employee_id, first_name, last_name, hire_date)
VALUES ( 1000, ‘John’, ‘Smith’, ‘01/01/01’);
B. INSERT INTO employees(employee_id, first_name, last_name, hire_date)
VALUES ( 1000, ‘John’, ‘Smith’, ’01 January 01’);
C. INSERT INTO employees(employee_id, first_name, last_name, Hire_date)
VALUES ( 1000, ‘John’, ‘Smith’, To_date(‘01/01/01’));
D. INSERT INTO employees(employee_id, first_name, last_name, hire_date)
VALUES ( 1000, ‘John’, ‘Smith’, 01-Jan-01);
Answer: A
Question: 282 (I)
User Mary has a view called EMP_DEPT_LOC_VU that was created based on the
EMPLOYEES, DEPARTMENTS, and LOCATIONS tables. She has the privilege to
create a public synonym, and would like to create a synonym for this view that can be
used by all users of the database.
Which SQL statement can Mary use to accomplish that task?
A. CREATE PUBLIC SYNONYM EDL_VU
ON emp_dept_loc_vu;
B. CREATE PUBLIC SYNONYM EDL:VU
FOR mary (emp_dept_loc_vu);
C. CREATE PUBLIC SYNONYM EDL_VU
FOR emp_dept_loc_vu;
D. CREATE SYNONYM EDL_VU
ON emp_dept_loc_vu
FOR EACH USER;
E. CREATE SYNONYM EDL_VU
FOR EACH USER
ON emp_dept_loc_vu;
F. CREATE PUBLIC SYNONYM EDL_VU
ON emp_dept_loc_vu
FOR ALL USERS;
Answer: A
Question: 283 (E)
Exhibit
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 170 of 179
The COMMISSION column shows the monthly commission earned by the employee.
Which two tasks would require subqueries or joins in order to be performed in a single step?
(Choose two.)
A. listing the employees who earn the same amount of commission as employee 3
B. finding the total commission earned by the employees in department 10
C. finding the number of employees who earn a commission that is higher than the average
commission of the company
D. listing the departments whose average commission is more that 600
E. listing the employees who do not earn commission and who are working for department 20 in
descending order of the employee ID
F. listing the employees whose annual commission is more than 6000
Answer: A, C
Question: 284 (I)
Examine the statement:
Create synonym emp for hr.employees;
What happens when you issue the statement?
A. An error is generated.
B. You will have two identical tables in the HR schema with different names.
C. You create a table called employees in the HR schema based on you EMP table.
D. You create an alternative name for the employees table in the HR schema in your own
schema.
Answer: D
Question: 285 (H)
Examine the structure of the EMPLOYEES table:
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2 (25)
LAST_NAME VARCHAR2 (25)
HIRE_DATE DATE
Which UPDATE statement is valid?
A. UPDATE employees
SET first_name = ‘John’
SET last_name = ‘Smith’
WHERE employee_id = 180;
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 171 of 179
B. UPDATE employees
SET first_name = ‘John’,
SET last_name = ‘Smoth’
WHERE employee_id = 180;
C. UPDATE employee
SET first_name = ‘John’
AND last_name = ‘Smith’
WHERE employee_id = 180;
D. UPDATE employee
SET first_name = ‘John’, last_name = ‘Smith’
WHERE employee_id = 180;
Answer: D
Question: 286 (J)
What is true about sequences?
A. The start value of the sequence is always 1.
B. A sequence always increments by 1.
C. The minimum value of an ascending sequence defaults to 1.
D. The maximum value of descending sequence defaults to 1.
Answer: A
Question: 287 (B)
The STUDENT_GRADES table has these columns
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
Which statement finds students who have a grade point average (GPA) greater than 3.0
for the calendar year 2001?
A. SELECT student_id, gpa
FROM student_grades
WHERE semester_end BETWEEN ’01-JAN-2001’ AND ’31-DEC-2001’
OR gpa > 3.;
B. SELECT student_id, gpa
FROM student_grades
WHERE semester_end BETWEEN ’01-JAN-2001’ AND ’31-DEC-2001’
AND gpa gt 3.0;
C. SELECT student_id, gpa
FROM student_grades
WHERE semester_end BETWEEN ’01-JAN-2001’ AND ’31-DEC-2001’
AND gpa > 3.0;
D. SELECT student_id, gpa
FROM student_grades
WHERE semester_end BETWEEN ’01-JAN-2001’ AND ’31-DEC-2001’
AND gpa > 3.0;
E. SELECT student_id, gpa
FROM student_grades
WHERE semester_end > ’01-JAN-2001’ OR semester_end < ’31-DEC-2001’
AND gpa >= 3.0;
Answer: C
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 172 of 179
Question: 288 (D)
Exhibit
ORDERS
ORD_ID ORD_DATE CUST_ID ORD_TOTAL
100 12-JAB-2000 15 10000
101 09-MAR-2000 40 8000
102 09-MAR-2000 35 12500
103 15-MAR-2000 15 12500
104 25-JUN-2000 15 6000
105 18-JUL-2000 20 5000
106 18-JUL-2000 35 7000
108 04-AUG-2000 10 8000
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 173 of 179
CUSTOMERS
CUST_ID CUST_NAME CITY
10 Smith Los Angeles
15 Bob San Francisco
20 Martin Chicago
25 Mary New York
30 Rina Chicago
35 Smith New York
40 Linda New York
Evaluate this SQL statement:
SELECT cust_id, ord_total
FROM orders
WHERE ord_total > ANY (SELECT ord_total
FROM orders
WHERE cust_id IN (SELECT cust_id
FROM customers
WHERE city LIKE
‘New York’));
What is the result when the above query is executed?
A.
CUST_ID ORD_TOTAL
15 10000
40 8000
35 12500
15 12500
10 8000
B.
CUST_ID ORD_TOTAL
15 10000
35 12500
15 12000
C.
CUST_ID ORD_TOTAL
15 10000
40 8000
15 12000
15 6000
20 5000
35 7000
20 6500
10 8000
D.
CUST_ID ORD_TOTAL
15 6000
20 5000
20 6500
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 174 of 179
E. The query returns no rows.
F. The query fails because ANY is not a valid operator with a subquery.
Answer: A
Question: 289 (E)
Which two statements about subqueries are true? (Choose two.)
A. A single row subquery can retrieve data from only one table.
B. A SQL query statement cannot display data from table B that is referred to in its subquery,
unless table B is included in the main query’s FROM clause.
C. A SQL query statement can display data from table B that is referred to in its subquery, without
including B in its own FROM clause.
D. A single row subquery can retrieve data from more than one table.
E. A single row subquery cannot be used in a condition where the LIKE operator is used for
comparison. F. A multiple-row subquery cannot be used in an INSERT statement to insert
multiple rows at a time.
Answer: D, F
Question: 290 (E)
What is true regarding subqueries?
A. The inner query always sorts the results of the outer query
B. The outer query always sorts the results of the inner query
C. The outer query must return a value to the inner query
D. The inner query returns a value to the outer query
E. The inner query must always return a value or the outer query will give an error
Answer: D
Question: 291 (C)
For which two actions can you use the TO_DATE function? (Choose two.)
A. Convert any date literal to a date
B. Convert any numeric literal to a date
C. Convert any date to a character literal
D. Format ‘January 10 1999’ for input
E. Format ’10-JAN-99’ to ‘January 10 1999’
Answer: A, D
Question: 292 (B)
EXHIBIT, Emp Table
Exhibit A
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 175 of 179
Exhibit B
Examine the data from the EMP table.
Evaluate this SQL statement:
SELECT * FROM emp
WHERE commission = (SELECT commission
FROM emp
WHERE emp_id=3);
What is the result when the query is executed?
A. Exhibit A
B. Exhibit B
C. The query returns no rows
D. The query fails because the outer query is retrieving more than one column
E. The query fails because both the inner and outer queries are retrieving data from the same
table.
Answer: C
Question: 293
Which three statements about subqueries are true? (Choose three.)
A. A main query can have more than one subquery.
B. A subquery can have more than one main query.
C. The subquery and main query must retrieve data from the same table.
D. The subquery and main query can retrieve data from different tables.
E. Only one column or expression can be compared between the subquery and main query.
F. Multiple columns or expression can be compared between the subquery and main query.
Answer: A, C, E
Question: 294
Evaluate this SQL statement:
SELECT e.emp_name, d.dept_name
FROM employees e
JOIN departments d
USING (department_id)
WHERE d.department_id NOT IN (10,40)
ORDER BY dept_name;
The statement fails when executed. Which change fixes the error?
A. remove the ORDER BY clause
B. remove the table alias prefix from the WHERE clause
C. remove the table alias from the SELECT clause
D. prefix the column in the USING clause with the table alias
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 176 of 179
E. prefix the column in the ORDER BY clause with the table alias
F. replace the condition
”d.department_id NOT IN (10,40)”
in the WHERE clause with
”d.department_id <> 10 AND d.department_id <> 40”
Answer: C
Question: 295
Evaluate the SQL statement:
SELECT LPAD (salary,10,*)
FROM EMP
WHERE EMP_ID = 1001;
If the employee with the EMP_ID 1001 has a salary of 17000, what is displayed?
A. 17000.00
B. 17000*****
C. ****170.00
D. **17000.00
E. an error statement
Answer: E
Question: 296
The EMP table contains these columns:
EMPLOYEE ID NUMBER(4)
EMPNAME VARCHAR2 (25)
SALARY NUMBER(9, 2)
HIRE_DATE DATE
You query the database with this SQL statement:
SELECT empname, hire_date HIREDATE, salary
FROM EMP
ORDER BY hire_date;
How will the results be sorted?
A - randomly
B - ascending by date
C - descending by date
D - ascending alphabetically
E - descending alphabetically
Answer: B
Question: 297
Examine the description of the MARKS table:
STD_ID NUMBER(4)
STUDENT_NAME VARCHAR2(30)
SUBJ1 NUMBER(3)
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 177 of 179
SUBJ2 NUMBER(3)
SUBJ3 NUMBER(3)
SUBJ1, SUBJ2, and SUBJS indicate the marks (grades) obtained by a student in the three
subjects.
Which two statements are valid? (Choose two.)
A - SELECT SUM(subj1, subj2, subj3)
FROM marks;
B - SELECT SUM(subj1 + subj2 + subj3)
FROM marks;
C - SELECT SUM(subj1), SUM(subj2), SUM(subj3)
FROM marks;
D - SELECT MAX(subj1, subj2, subj3)
FROM marks;
E - SELECT MINIMUM(subj1)
FROM marks;
F - SELECT COUNT(std_id)
FROM marks
WHERE subj1 >= AVG(subj1);
Answer: B, C
Question: 298
Exhibit:
Examine the structure of the EMPLOYEES, DEPARTMENTS, and LOCATIONS tables. Two new
departments are added to your company as shown:
DEPARTMENT_ID DEPARTMENT_NAME MGR_ID LOCATION_ID
9998 Engineering 123
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 178 of 179
9999 Administrative Boston
You need to list the names of employees, the department IDs, the department names, and the
cities where the departments are, even if there are no employees in the departments and even if
the departments are not yet assigned to a location. You need to join the EMPLOYEES,
DEPARTMENTS, and LOCATIONS tables to retrieve this information.
Which statement do you execute to retrieve this information?
A - SELECT e.Iast_name, d.department_id,
d.department_name, I.city
FROM departments d
RIGHT OUTER JOIN employees e
ON d.department_id = e.department_id
RIGHT OUTER JOIN locations I
ON d.Iocation_id = l.location_id;
B - SELECT e.Iast_name, d.department_id,
d.department_name, I.city
FROM departments d
FULL OUTER JOIN employees e
ON d.department_id = e.department_id
FULL OUTER JOIN locations I
ON d.Iocation_id = I.Iocation_id;
C - SELECT e.Iast_name, d.department_id,
d.department_name, I.city
FROM departments d
LEFT OUTER JOIN employees e
ON d.department_id = e.department_id
LEFT OUTER JOIN locations I
ON d.Iocation_id = l.location_id;
D - SELECT last_name, department_id,
department_name, city
FROM departments d
NATURAL JOIN employees e
NATURAL JOIN locations I;
Answer: C
Question: 299
In which three cases would you use the USING clause? (Choose three.)
A - You wantto create a nonequijoin.
B - The tables to be joined have multiple NULL columns.
C - The tables to be joined have columns of the same name and different data lypes.
D - The tables to be joined have columns with the same name and compatible data types.
E - You want to use a NATURAL join, but you want to restrict the number of columns in the join
condition.
Answer: C, D, E
Question: 300
Which two statements are true regarding the default behavior of the ORDER BY clause? (Choose
two.)
A - Null values are left out of the sort.
B - Character values are displayed from Z to A.
Exam Name: Introduction to Oracle9i: SQL
Exam Type: Oracle Exam Code: 1Z0-007
Doc. Type: Q & A with explanations Total Questions 301
Page 179 of 179
C - Date values are displayed with the earliest value first.
D - Null values are displayed last for descending sequences.
E - Numeric values are displayed with the lowest values first.
Answer: C, E
Question: 301
You need to create a table named ORDERS that contains four columns:
1. an ORDER_ID column of number data type
2. a CUSTOMER_ID column of number data type
3. an ORDER_STATUS column that contains a character data type
4. a DATE_ORDERED column to contain the date the order was placed
When a row is inserted into the table, if no value is provided for the status of the order, the value
PENDING should be used instead.
Which statement accomplishes this?
A - CREATE TABLE orders(
order_id NUMBER(10),
customer_id NUMBER(8),
order_status NUMBER(10) DEFAULT ‘PENDING’,
date_ordered DATE );
B - CREATE TABLE orders(
order_id NUMBER(10),
customer_id NUMBER(8),
order_status VARCHAR2(10) = ‘PENDING’,
date_ordered DATE );
C - CREATE OR REPLACE TABLE orders(
order_id NUMBER(10),
customer_id NUMBER(8),
order_status VARCHAR2(10) DEFAULT ‘PENDING’,
date_ordered DATE );
D - CREATE OR REPLACE TABLE orders (
order_id NUMBER(10),
customer_id NUMBER(8),
order_status VARCHAR2(10) = ‘PENDING’,
date_ordered DATE );
E - CREATE TABLE orders(
order_id NUMBER(10),
customer_id NUMBER(8),
order_status VARCHAR2(10) DEFAULT ‘PENDING’,
date_ordered DATE );
F - CREATE TABLE orders(
order_id NUMBER(10),
customer_id NUMBER(8),
order_status VARCHAR2(10) DEFAULT ‘PENDING’,
date_ordered VARCHAR2 );
Answer: E
End of Document

1 comment:

VMware Cloud Learning Video's

Here is a nice summary list of all VMworld US 2018 Breakout session with the respective video playback & download URLs. Enjoy! Bra...