Chapter 11
Chapter 11
Chapter 11
Bits:
-------------------------------------------QUESTION NO: 21
Which two statements are true about sequences created in a single instance database?
(Choose two.)
A. CURRVAL is used to refer to the last sequence number that has been generated
B. DELETE <sequencename> would remove a sequence from the database
C. The numbers generated by a sequence can be used only for one table
D. When the MAXVALUE limit for a sequence is reached, you can increase the
MAXVALUE limit by using the ALTER SEQUENCE statement
E. When a database instance shuts down abnormally, the sequence numbers that have
been cached but not used would be available once again when the database instance is
restarted
Answer: A,D
Explanation:
Gaps in the Sequence
Although sequence generators issue sequential numbers without gaps, this action
occurs independent of a commit or rollback. Therefore, if you roll back a statement
containing a sequence, the number is lost.
Another event that can cause gaps in the sequence is a system crash. If the sequence
caches values in memory, those values are lost if the system crashes.
Because sequences are not tied directly to tables, the same sequence can be used for
multiple tables.
However, if you do so, each table can contain gaps in the sequential numbers.
Modifying a Sequence
1ZO-051
If you reach the MAXVALUE limit for your sequence, no additional values from the
sequence are allocated and you will receive an error indicating that the sequence
exceeds the MAXVALUE. To continue to use the sequence, you can modify it by using
the ALTER SEQUENCE statement
To remove a sequence, use the DROP statement:
DROP SEQUENCE dept_deptid_seq;
QUESTION NO: 22
The ORDERS TABLE belongs to the user OE. OE has granted the SELECT privilege on
the ORDERS table to the user HR.
Which statement would create a synonym ORD so that HR can execute the following
query successfully?
SELECT * FROM ord;
A. CREATE SYNONYM ord FOR orders; This command is issued by OE.
B. CREATE PUBLIC SYNONYM ord FOR orders; This command is issued by OE.
C. CREATE SYNONYM ord FOR oe.orders; This command is issued by the database
administrator.
D. CREATE PUBLIC SYNONYM ord FOR oe.orders; This command is issued by the
database administrator.
Answer: D
Explanation:
Creating a Synonym for an Object
To refer to a table that is owned by another user, you need to prefix the table name with
the name of the user who created it, followed by a period. Creating a synonym
eliminates the need to qualify the object name with the schema and provides you with
an alternative name for a table, view, sequence, procedure, or other objects.
This method can be especially useful with lengthy object names, such as views.
In the syntax:
PUBLIC Creates a synonym that is accessible to all users synonym Is the name of the
synonym to be created object Identifies the object for which the synonym is created
Guidelines
The object cannot be contained in a package.
A private synonym name must be distinct from all other objects that are owned by the
same user.
If you try to execute the following command (alternative B, issued by OE):
1ZO-051
QUESTION NO: 24
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
Explanation:
QUESTION NO: 45
You work as a database administrator at ABC.com. You study the exhibit carefully.
Exhibit:
1ZO-051
You want to create a SALE_PROD view by executing the following SQL statements:
1ZO-051
QUESTION NO: 48
Which two statements are true regarding views? (Choose two.)
A. A sub query that defines a view cannot include the GROUP BY clause
B. A view is created with the sub query having the DISTINCT keyword can be updated
C. A Data Manipulation Language (DML) operation can be performed on a view that is
created with the sub query having all the NOT NULL columns of a table
D. A view that is created with the sub query having the pseudo column ROWNUM
keyword cannot be updated
Answer: C,D
Explanation:
Rules for Performing DML Operations on a View
You cannot add data through a view if the view includes:
Group functions
A GROUP BY clause
The DISTINCT keyword
The pseudocolumn ROWNUM keyword
Columns defined by expressions
NOT NULL columns in the base tables that are not selected by the view
QUESTION NO: 54
Which statements are correct regarding indexes? (Choose all that apply.)
A. For each data manipulation language (DML) operation performed, the corresponding
indexes are automatically updated.
B. A nondeferrable PRIMARY KEY or UNIQUE KEY constraint in a table automatically
creates a unique index.
C. A FOREIGN KEY constraint on a column in a table automatically creates a non
unique key
D. When a table is dropped, the corresponding indexes are automatically dropped
5
1ZO-051
Answer: A,B,D
Explanation:
QUESTION NO: 58
You are currently located in Singapore and have connected to a remote database in
Chicago.
You issue the following command:
Exhibit:
PROMOTIONS is the public synonym for the public database link for the
PROMOTIONS table.
What is the outcome?
A. Number of days since the promo started based on the current Singapore data and
time.
B. An error because the ROUND function specified is invalid
C. An error because the WHERE condition specified is invalid
D. Number of days since the promo started based on the current Chicago data and time
Answer: D
Explanation:
QUESTION NO: 62
Which object privileges can be granted on a view?
A. none
6
1ZO-051
B. DELETE, INSERT,SELECT
C. ALTER, DELETE, INSERT, SELECT
D. DELETE, INSERT, SELECT, UPDATE
Answer: D
Explanation: Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT
and UPDATE.
Incorrect answer:
AObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and
UPDATE
BObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and
UPDATE
CObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and
UPDATE
Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-12
QUESTION NO: 82
Which statement is true regarding synonyms?
A. Synonyms can be created only for a table
B. Synonyms are used to reference only those tables that are owned by another user
C. The DROP SYNONYM statement removes the synonym and the table on which the
synonym
has been created becomes invalid
D. A public synonym and a private synonym can exist with the same name for the same
table
Answer: D
Explanation:
QUESTION NO: 90
You are currently located in Singapore and have connected to a remote database in
Chicago. You issue the following command:
Exhibit:
1ZO-051
PROMOTIONS is the public synonym for the public database link for the
PROMOTIONS table.
What is the outcome?
A. Number of days since the promo started based on the current Chicago data and time
B. Number of days since the promo started based on the current Singapore data and
time.
C. An error because the WHERE condition specified is invalid
D. An error because the ROUND function specified is invalid
Answer: A
Explanation:
QUESTION NO: 92
Evaluate the following SQL statements:
Exhibit:
You issue the following command to create a view that displays the IDs and last names
of the sales staff in the organization.
Exhibit:
1ZO-051
Which two statements are true regarding the above view? (Choose two.)
A. It allows you to update job IDs of the existing sales staff to any other job ID in the
EMPLOYEES table
B. It allows you to delete details of the existing sales staff from the EMPLOYEES table
C. It allows you to insert rows into the EMPLOYEES table
D. It allows you to insert IDs, last names, and job IDs of the sales staff from the view if it
is used in multitable INSERT statements
Answer: B,D
Explanation:
Evaluate the following SQL statements that are executed in a user session in the
specified order:
CREATE SEQUENCE ord_seq;
SELECT ord_seq.nextval
9
1ZO-051
FROM dual;
INSERT INTO ord
VALUES (ord_seq.CURRVAL, 25-jan-2007,101);
UPDATE ord
SET ord_no= ord_seq.NEXTVAL
WHERE cust_id =101;
What would be the outcome of the above statements?
A. All the statements would execute successfully and the ORD_NO column would
contain the value 2 for the CUST_ID 101.
B. The CREATE SEQUENCE command would not execute because the minimum value
and maximum value for the sequence have not been specified.
C. The CREATE SEQUENCE command would not execute because the starting value
of the sequence and the increment value have not been specified.
D. All the statements would execute successfully and the ORD_NO column would have
the value 20 for the CUST_ID 101 because the default CACHE value is 20.
Answer: A
Explanation:
1ZO-051
11
1ZO-051
A. CREATE VIEW v3
AS SELECT * FROM SALES
WHERE cust_id = 2034
12
1ZO-051
13
1ZO-051
1ZO-051
The command to create a table fails. Identify the reason for the SQL statement failure?
(Choose all that apply.)
A. You cannot use SYSDATE in the condition of a CHECK constraint.
B. You cannot use the BETWEEN clause in the condition of a CHECK constraint.
C. You cannot use the NEXTVAL sequence value as a DEFAULT value for a column.
D. You cannot use ORD_NO and ITEM_NO columns as a composite primary key
because ORD NO is also the FOREIGN KEY.
Answer: A,C
Explanation:
CHECK Constraint
The CHECK constraint de
15
1ZO-051
fines a condition that each row must satisfy. The condition can use the same constructs
as the query conditions, with the following exceptions:
References to the CURRVAL, NEXTVAL, LEVEL, and ROWNUM pseudocolumns
Calls to SYSDATE, UID, USER, and USERENV functions
Queries that refer to other values in other rows
A single column can have multiple CHECK constraints that refer to the column in its
definition.
There is no limit to the number of CHECK constraints that you can define on a column.
CHECK constraints can be defined at the column level or table level.
CREATE TABLE employees
(...
salary NUMBER(8,2) CONSTRAINT emp_salary_min
CHECK (salary > 0),
16
1ZO-051
17
1ZO-051
18
1ZO-051
1ZO-051
D. The OR REPLACE option is used to change the definition of an existing view without
dropping and recreating it.
E. The WITH CHECK OPTION constraint can be used in a view definition to restrict the
columns displayed through the view.
Answer: B,D
Explanation:
20
1ZO-051
A. 1
B. 10
C. 100
D. an error
Answer: A
Explanation:
But why the answer is not "C" ?
Because you didn't specify the MINVALUE for the sequence. If you check the sequence
definition that you created it will have the default value of 1, which it reverts to when
cycling.
If you wanted to keep the minimum value you would need to specify it in the sequence
creation.
sequence Is the name of the sequence generator
INCREMENT BY n Specifies the interval between sequence numbers, where n is an
integer (If this clause is omitted, the sequence increments by 1.)
START WITH n Specifies the first sequence number to be generated (If this clause is
omitted, the sequence starts with 1.)
MAXVALUE n Specifies the maximum value the sequence can generate
NOMAXVALUE Specifies a maximum value of 10^27 for an ascending sequence and
1 for a descending sequence (This is the default option.)
MINVALUE n Specifies the minimum sequence value
NOMINVALUE Specifies a minimum value of 1 for an ascending sequence and
(10^26) for a descending sequence (This is the default option.)
CYCLE | NOCYCLE Specifies whether the sequence continues to generate values after
reaching its maximum or minimum value (NOCYCLE is the default option.)
CACHE n | NOCACHE Specifies how many values the Oracle server preallocates and
keeps in memory (By default, the Oracle server caches 20 values.)
21
1ZO-051
Explanation:
1ZO-051
23