Creating Other Schema Objects Questions
Creating Other Schema Objects Questions
http://www.tutorialspoint.com/sql_certificate/creating_other_schema_objects_questions.htm
Copyright © tutorialspoint.com
1. Which database object among the following provides a layer of abstraction between
the users and the data?
A. Table
B. Rows
C. Views
D. Synonyms
Answer: C, D. Views and Synonyms do not store data themselves. A view is a temporary or virtual
table used to retrieve data stored in underlying database tables.
2. Which of the following data base objects can generate serial numbers?
A. Synonyms
B. Views
C. Tables
D. Sequences
Answer: D. A sequence can be created to generate a series of integers. The values generated by
a sequence can be stored in any table. A sequence is created with the CREATE SEQUENCE
command.
Answer: C, D. DML operations aren't permitted on views that include group functions, a GROUP
BY clause, the ROWNUM pseudocolumn, or the DISTINCT keyword.
Answer: B, C. A view is a temporary or virtual table used to retrieve data stored in underlying
database tables. The view query must be executed each time the view is used. A view can be used
to simplify queries or restrict access to sensitive data.
5. In which of the below scenarios, DML operations on a view are not possible?
Answer: C.
Consider the given table structure and the following statement and answer the
questions 7 to 9 that follow:
7. You issue the below query. How many columns will the user see as a result of the
below query?
A. 0
B. 1
C. 2
D. 4
Answer: D. Since the view definition is based on four columns from the EMPLOYEES table, a query
on a view with all column will show those four columns only.
8. You need to get the department name in addition to the above 4 columns. Which of
the following query will give you the required results?
Answer: A. A view can be joined with other tables or views in a SELECT query.
9. You need to find the maximum salary along with the department name in addition to
the 4 columns selected in the view. Which of the following query will give you the
required results?
Answer: B.
A. PUBLIC and PRIVATE synonyms can have the same name for the same table
B. DROP SYNONYM will remove a synonym
C. DROP PUBLIC SYNONYM can be executed only by a SYSDBA
D. None of the above
Answer: A, C. A synonym can be a private synonym, which users use to reference objects they
own,or a public synonym, which users use to access another user's database objects. Only SYSDBA
or a user with DBA privileges can create a public synonym.
11. What is true about creating a view? (Choose the most appropriate answer)
12. Which of the following privileges are required to create views in one's own schema?
Answer: B. CREATE VIEW privilege is required by a user to create a view in its own schema.
13. Which of the following privileges are required to create views in someone else's
schema?
14.Which of the following are supported for an object view or relational view?
A. LOBs
B. Object types
C. REF data types
D. All of the above
Answer: D.
A. Simple views
B. Complex views
C. Both A and B
D. None of the above
Answer: C. Simple and Complex views are two types of views. Simple views are based on a
subquery that references only one table and doesn't include group functions, expressions, or
GROUP BY clauses. Complex views are based on a subquery that retrieves or derives data from
one or more tables and can contain functions or grouped data.
A. DML statements can be issued most of the times against simple views
B. There is only one source base table
C. No group functions are used
D. All of the above
Answer: D. Simple views are based on a subquery that references only one table and doesn't
include group functions, expressions, or GROUP BY clauses.
Answer: D. Complex views are based on a subquery that retrieves or derives data from one or
more tables and can contain functions or grouped data.
18.Which keyword combination should be used to implicitly drop a view (if it exists) and
create a new view with the same name?
A. CREATE VIEW
B. REPLACE VIEW
C. CREATE OR REPLACE VIEW
D. None of the above
Answer: C. The OR REPLACE option notifies Oracle 11g that a view with the same name might
already exist; if it does, the view's previous version should be replaced with the one defined in the
new command.
Answer: D.
A. Inline Views
B. Simple Views
C. Complex Views
D. Composite Views
A. Composite View
B. Simple View
C. Complex View
D. None of the above
23.Which of the following can create a view even if the base table(s) does not exist?
A. NOFORCE
B. FORCE
C. OR REPLACE
D. CREATE VIEW
Answer: B. Ff you include the FORCE keyword in the CREATE clause, Oracle 11g creates the view
in spite of the absence of any referenced tables. NOFORCE is the default mode for the CREATE
VIEW command, which means all tables and columns must be valid, or the view isn't created.
24.Which of the following commands ensures that no DML operations can be performed
on a view?
A. NOFORCE
B. FORCE
C. WITH READ ONLY
D. OR REPLACE
Answer: C. The WITH READ ONLY option prevents performing any DML operations on the view.
This option is used often when it's important that users can only query data, not make any changes
to it.
Answer: B, C. NOFORCE is the default mode for the CREATE VIEW command, which means all
tables and columns must be valid, or the view isn't created.
A. Object privileges are lost when a view is created using this keyword
B. There is no need of re granting the object privileges previously granted on it
C. Neither of A nor B
D. None of the above
Answer: B. The OR REPLACE option notifies Oracle 11g that a view with the same name might
already exist; if it does, the view's previous version should be replaced with the one defined in the
new command.
27.What is true with respect to accessing the below view? (Assume the table structure
given)
A. The view has to be accessed by the original column names defined in the base table
B. The view has to be accessed by the aliases given in the view query
C. View is a simple view
D. None of the above
Answer: B, C. View must refer the column alias if the view definition contains alias for the
columns.
28.What is true with respect to accessing the below view? (Assume the table structure
given)
A. It is not mandatory that the number of aliases match the no. of expressions in the sub-query
B. It is mandatory that the no. of aliases listed must match the no. of expressions selected in the
sub-query
C. It is mandatory to give aliases while creating a view
D. None of the above
Answer: B. If the alias are specified in the view header, same number of columns must be
selected in the SELECT query.
29. Consider the following statement and the given table structure:
A. Column aliases are listed in a random order as the columns in the sub-query
B. Column aliases are listed in the same order as the columns in the sub-query
C. Column aliases are mandatory while using the CREATE OR REPLACE keyword
D. We cannot use concatenation when we use the CREATE OR REPLACE
Answer: B.
Consider the following statement and answer the questions 30 to 34 that follow:
Answer: C. Specifying alias name is good practice to improve the readability of the code and the
view queries.
Answer: B. The sequence of the column alias not matters much as they don't carry any
behavioral attribute.
Answer: C. The view DEPT_SUM_VU is a complex view. DML operations cannot be performed on a
complex view.
A. The view can be updated to update the values in EMPLOYEES and DEPARTMENTS tables
B. Data in EMPLOYEES and DEPARTMENTS tables cannot be deleted through view
C. Data in EMPLOYEES and DEPARTMENTS tables can be inserted through view
D. A column can be added to EMPLOYEES table through the view
34.Suppose you select DISTINCT departments and employee salaries in the view query
used in above question. What will be the outcome if you try to remove rows from the
view dept_sum_vu?
Answer: C. The view DEPT_SUM_VU is still a complex view as it uses DISTINCT keyword. Hence,
DML operations are not possible on it.
37. The JOB_HISTORY table is owned by a user "Andy". Andy grants the SELECT privilege
on the JOB_HISTORY table to another user "HR". Which statement would create a
synonym EMP_JOBS so that "HR" can execute the following query successfully?(Assume
the structure of tables as given)
B. HR issues -
CREATE SYNONYM EMP_JOBS for andy.JOB_HISTORY
C. HR issues -
CREATE PUBLIC SYNONYM EMP_JOBS FOR andy.JOB_HISTORY
Answer: B. Only SYSDBA or a user with DBA privileges can create public synonyms.
38.Which keyword can assure that the DML operations performed on the view stay in
the domain of the view?
A. OR REPLACE
B. CREATE
C. WITH CHECK OPTION
D. None of the above
Answer: C. The WITH CHECK OPTION constraint ensures that any DML operations performed on
the view (such as adding rows or changing data) don't prevent the view from accessing the row
because it no longer meets the condition in the WHERE clause.
Consider the following table structure and the given statement and answer the
questions 39 and 40 that follow:
Answer: B. The WITH CHECK OPTION constraint ensures that any DML operations performed on
the view (such as adding rows or changing data) don't prevent the view from accessing the row
because it no longer meets the condition in the WHERE clause. An ORA error will be thrown if an
INSERT or UPDATE will be executed on any row with a department_id other than 100.
Answer: C. If the view with CHECK OPTION is updated and new record's value violates the scope of
the view, ORA exception "ORA-01402: view WITH CHECK OPTION where-clause violation" is raised.
A. INSERTs or UPDATEs performed through the view cannot create rows that the view cannot
select
B. Only INSERTs performed through the view cannot create rows that the view cannot select
C. Only UPDATEs performed through the view cannot create rows that the view cannot select
D. None of the above
Answer: A.
Answer: B. The WITH READ ONLY option prevents performing any DML operations on the view.
This option is used often when it's important that users can only query data, not make any changes
to it.
Consider the table structure and the given statement and answer the questions 43, 44
and 45 that follow:
Answer: B, C. DML operations are not permitted on view which are created with READ ONLY
option.
44.How many rows can be deleted from the view as shown above?
Answer: C. DML operations are not permitted on view which are created with READ ONLY option.
45.Which of the following statements will drop the view created as above?
Answer: C. Read only view can be dropped using the DROP VIEW command.
A. The columns in the view from the base tables are also dropped
B. The definition of the view is removed from the database
C. Dropping of a view has no effect on the underlying base table
D. None of the above
Answer: B, C.
Answer: C.
A. It generates integers
B. It is a shareable object
C. Can be used to create a PRIMARY KEY value
D. All of the above
Answer: D. A sequence speeds up the efficiency of accessing sequence values when cached in
memory
A. The integers generated through a sequence for one table cannot be used by other tables
B. A sequence can only be incremented
C. A sequence becomes invalid if another sequence generates the same integers
D. A sequence can be used by many tables and they can be incremented or decremented
Answer: D.
Consider the following statement and answer the questions 51 to 59 that follow:
A. 1
B. 100
C. 101
D. 9999
Answer: C. The START WITH clause establishes the starting value for the sequence. Oracle 11g
begins each sequence at 1 unless another value is specified in the START WITH clause.
A. 0
B. 100
C. 101
D. 9999
Answer: D. The MINVALUE and MAXVALUE clauses establish a minimum or maximum value for
the sequence.
A. 102
B. 100
C. 99
D. 9999
Answer: A. The INCREMENT BY clause specifies the interval between two sequential values. If the
sequence is incremented by a positive value, the values the sequence generates are in ascending
order. However, if a negative value is specified, the values the sequence generates are in
descending order. If the INCREMENT BY clause isn't included when the sequence is created, the
default setting is used, which increases the sequence by one for each integer generated.
54.What will be the next value after the maximum integer 9999 is reached by this
sequence?
A. 101
B. No value
C. It will throw an ORA error
D. None of the above
Answer: B. The CYCLE and NOCYCLE options determine whether Oracle 11g should begin
reissuing values from the sequence after reaching the minimum or maximum value.
55.How many values will Oracle pre allocate in memory based on the sequence given
above?
A. 20
B. 0
C. 100
D. 9999
Answer: A.
Assuming that the last value the sequence generated was 200, what will be the outcome of this
query?
A. 200
B. 101
C. 9999
D. 201
Answer: D. The NEXTVAL pseudocolumn will generate the next unique integer of the sequence.
Assuming that the last value the sequence generated was 200, what will be the outcome of this
query?
A. 200
B. 101
C. 9999
D. 201
Answer: A. The CURRVAL pseudocolumn will generate the current unique integer already
generated by the sequence.
58.Suppose you need to change the start value of this sequence to 1000. Which of the
following statements will help?
A. ALTER dept_deptid_seq
INCREMENT BY 100
START WITH 1000
MAXVALUE 9999
NOCACHE
NOCYCLE;
B. The sequence has to be dropped and re-created to start the sequence from 1000.
Answer: B. Starting number of a sequence cannot be modified. Oracle raises the exception "ORA-
02283: cannot alter starting sequence number".
A. ORA error
B. The maximum value for the altered sequence will now be 99
C. Neither of A nor B
D. None of the above
Answer: A. The MAXVALUE cannot be less than the START WITH value while altering a sequence.
Answer: C. The CYCLE and NOCYCLE options determine whether Oracle 11g should begin
reissuing values from the sequence after reaching the minimum or maximum value. If the CYCLE
option is specified and Oracle 11g reaches the maximum value for an ascending sequence or the
minimum value for a descending sequence, the CYCLE option initiates the cycle of numbers again.
Answer: B. The pseudocolumn NEXTVAL (NEXT VALUE) is used to actually generate the sequence
value. In other words, it calls the sequence object and requests the value of the next number in the
sequence. After a value is generated, it's stored in the CURRVAL (CURRENT VALUE) pseudocolumn
so that you can reference it again.
Answer: B.
Answer: C, D. The sequence can be used in SELECT query, PL/SQL cursor or in IAS (INSERT-AS-
SELECT)direct operations.
Answer: D.
Consider the given statement and answer the questions 65 and 66 that follow:
66.What will be the outcome of this statement if the CURRVAL is replaced with
NEXTVAL? (Assume that emp_empid_seq is generated to generate employee ID values)
67.You need to insert a new department named "HR" in the location ID 1000. Which of
the following statements will give you the required results?
Answer: A.The option C will cause a 'Unique constraint violation' as it will try to insert current
value of department id which aleady exists in the DEPARTMENTS table.
68.Suppose you execute the below query before inserting the values as shown in the
option A in question 67. What will be the outcome of the query?
A. ORA error
B. It will give the current value of the sequence
C. Neither of A nor B
D. None of the above
Answer: B. When a user logs in to Oracle 11g, no value is initially stored in the CURRVAL
pseudocolumn; the current value is NULL. After a NEXTVAL call has been issued to generate a
sequence value, CURRVAL stores that value until the next value is generated. CURRVAL contains
only the last value generated.
Answer: C. If the NOCACHE option is specified when the sequence is created, each number is
generated when the request is received. However, if an organization's transactions require large
amounts of sequential numbers throughout a session, the CACHE option can be used to have
Oracle 11g generate a set of values ahead of time and store them in the server's memory. Then,
when a user requests a sequence value, the next available value is assigned-without Oracle 11g
having to generate the number. On the other hand, if the CACHE option isn't specified, Oracle 11g
assumes a default option of CACHE 20 and stores 20 sequential values in memory automatically
for users to access.
Suppose the employee transaction rolled back. What will be the result of the above query?
Answer: C. Sequence values are unaffected by commit or rollback. If a transaction which uses
sequence generator is rolled back, the sequence values are wasted and cannot be recovered.
Answer: B. To alter a sequence, the sequence must be in your own schema, or you must have the
ALTER object privilege on the sequence, or you must have the ALTER ANY SEQUENCE system
privilege.
A. The existing integers already generated by the sequence are altered as well
B. Only the future integers are affected
C. The sequence stops caching the future integers
D. None of the above
Answer: B. By using the ALTER SEQUENCE command, any changes are applied only to values
generated after the modifications are made.
74.Suppose you need to drop a sequence. Which of the following commands will help?
75.Which of the following privileges will allow you to drop a sequence? (Choose the
most appropriate answer)
A. ALTER SEQUENCE
B. ALTER TABLE
C. DROP SEQUENCE
D. DROP ANY SEQUENCE
Answer: D. To drop a sequence, either the sequence must be in your own schema or you must
have the DROP ANY SEQUENCE system privilege.
Answer: D. Indexes can be created manually as well as automatically following certain actions
like creating a primary key or unqiue constraint.
A. ROWNUM
B. ROWID
C. Sequence
D. None of the above
Answer: B. An Oracle 11g index is a database object that stores a map of column values and the
ROWIDs of matching table rows. A ROWID is the physical address of a table row.
Answer: B.
Answer: D.
80.What will happen if an index is dropped?
Answer: D. Indexes are the objects which are physically stored in schema. Dropping an index
doesn't impacts other objects.
A. The indexes still remain as they are logically and independent objects
B. The indexes in the table are also dropped
C. Neither of A nor B
D. None of the above
Answer: B.
Answer: C, D.
Answer: B, C, D. The schema object for which you are creating the synonym can be of the
following types:Table or object table, View or object view, Sequence, Stored procedure, function,
or package, Materialized view, Java class schema object, User-defined object type, Synonym
84. Which of the following can you use to reference a table owned by another user?
A. INDEX
B. TABLE
C. SYNONYMS
D. SEQUENCES
A. PRIMARY KEY
B. UNIQUE KEY
C. FOREIGN KEY
D. None of the above
Answer: C.
A. Bitmap
B. B-tree
C. Unique
D. Non-unique
Answer: A, B. The B-tree (balanced-tree) index is the most common index used in Oracle. You
can create this type of index with a basic CREATE INDEX statement. A bitmap index varies in
structure and use from a B-tree index. This index is useful for improving queries on columns that
have low selectivity (low cardinality, or a small number of distinct values).
Answer: A.
A. It specifies that the value of the column(s) upon which the index is created must be unique
B. You cannot use the UNIQUE keyword when creating indexes
C. It specifies that the index that is created can be used only by one table
D. None of the above
Answer: A. A unique index is typically created automatically when a PRIMARY KEY or UNIQUE
constraint is defined on a column. Unique indexes can also be explicitly created by including the
UNIQUE keyword in the CREATE INDEX statement.
89.What will happen when you specify the keyword BITMAP while creating an Index?
Answer: C.
90.You have queries written which are expected to retrieve less than 2% to 4% of rows.
Which of the following can be applied on the relevant tables to achieve the query
performance of such query? (Choose the best answer)
A. Indexes
B. UNION set operator
C. MINUS set operator
D. None of the above
Answer: A. Indexes are the best way to achieve query performance. Heavy IO operations can be
reduced and simplified using index scans.
Answer: C, D.
92.The table EMPLOYEES is updated frequently. When can Indexes be created on this
table? (Choose the most appropriate answer)
Answer: A. Frequent or bulk DML operations on a table with an index add an overhead of
maintaining the index segment, which might affect the DML operation performance.
93.Consider the following query and answer the following query. Assume that the
EMPLOYEE_ID , DEPARTMENT_ID and FIRST_NAME columns of EMPLOYEES table are
indexed. (Assume the table structure as given)
A. Yes
B. No
C. It might help
D. None of the above
Answer: B. Indexes are not used when the query predicates do not contain the columns on which
the index is created.
C. DROP INDEX;
Answer: B. You must have the DROP ANY INDEX privilege to drop an index.