Sunday, April 08, 2007

OCA Oracle 10g Ch3 Database storage and Schema Objects

OCA Oracle 10g

Review Questions

1. Which of the following statements about tablespaces is true?
A. A tablespace is the physical implementation of logical structure called a namespace.
B. A tablespace can hold the objects of only one schema.
C. A bigfile tablespace can have only one datafile.
D. The SYSAUX tablespace is an optional tablespace only created if you install certain database
options.
-----
Ans: C
Bigfile tablespaces are new to Oracle10g and can have only a single datafile. The traditional
or smallfile tablespace can have many datafiles.

2. Automatic segment space management on the tablespace causes which of the following table
attributes in that tablespace to be ignored?
A. The whole storage clause
B. NEXT and PCTINCREASE
C. BUFFERPOOL and FREEPOOL
D. PCTFREE and PCTUSED
Ans: D.
Segment space management refers to free space management, with automatic segment space
management using bitmaps instead of FREELISTS, PCTFREE, and PCTUSED.

3. Which objects share the same namespace and therefore cannot have the same name?
A. Tables and indexes
B. Tables and procedures
C. Tables and constraints
D. Tables and triggers
--
Ans: B. Indexes, constraints, and triggers all have separate namespaces. Tables share a namespace with
views, sequences, private synonyms, procedures, functions, packages, materialized views, and
user-defined types. Objects within the same schema sharing a namespace must have unique names.

4. Which is not a type of segment that is stored in a tablespace?
A. Undo
B. Redo
C. Permanent
D. Temporary
--
Ans: B.
Redo information is not stored in a segment; it is stored in the redo logs. Undo segments are
stored in the undo tablespace, temporary segments are in the temporary tablespace, and permanent
segments go into all the other tablespaces.

5. With which parameters do you specify unlimited datafile growth?
A. MAXSIZE UNLIMITED
B. UNLIMITED GROWTH
C. MAXEXTENTS UNLIMITED
D. Datafile size cannot change.
--
Ans: A.
The autoextend MAXSIZE parameter tells Oracle how large a data or temp file can grow to.
UNLIMITED specifies no bounds to the automatic growth.

6. Which of the following is not a character datatype that can be used in a table column definition?
A. char
B. varchar
C. nvarchar2
D. string
---
Ans D.
The character datatypes include char, nchar, varchar, varchar2, nvarchar2, and long
but do not include string.

7. With which numeric datatype can you represent infinity?
A. double
B. float
C. binary_float
D. Infinity cannot be represented in the database.
---
Ans C.
With Oracle 6 through Oracle 9i, infinity could not be represented in the database. With
Oracle10g, however, binary_float and binary_double can represent infinity, not a number
(NAN), as well as several other special values.

8. A table name can never include the special meta-character dollar sign ($).
A. True
B. False
C. Only if the table name is enclosed in double quotes
D. Only if the table name is enclosed in single quotes
--
Ans B. Objects in an Oracle10g database can always include letters, numbers, and the characters
$, _, and # (dollar sign, underscore, and pound sign). Names can include any other character only
if they are enclosed in double quotes. The character dollar sign is not a special meta-character in
an Oracle10g database.

9. Which of the following column specifications results in a column that will store time values
down to the microsecond decimals of precision?
A. timestamp(3)
B. time(3)
C. datetime(3)
D. date(3)
--
Ans: A.
There is no time or datetime datatype in Oracle10g. The date datatype cannot store
subsecond granularity. The timestamp datatype stores subsecond granularity, defaulting to
six digits of precision.

10. Which type of index can specify as a unique index?
A. Bitmap
B. Heap organized
C. Btree
D. XOR
--
Ans C.
Heap organized is a table that is not index organized; it is not an index type. XOR is bitwise
function and not an index type. Bitmap is an index type, but cannot be used for a unique index.
Btree indexes make fine unique indexes.

11. Which operation can you not do to a table that is created with the following SQL statement?
CREATE TABLE properties
("Location" NUMBER primary key
,value NUMBER(15)
,lot varchar2(12)
,constraint positive_value check
(value > 0)
);
A. Rename the primary key to properties.
B. Insert a null into the value column.
C. Add a column named owner.
D. Rename the index supporting primary key to properties.
E. None of the above.
--
Ans: E. You can rename both a constraint and an index to the same name as a table. they are in
separate namespaces. Columns can be added, and owner is a valid column name. If the check
constraint condition evaluates to FALSE, the data value will not be allowed; if the condition evaluates
to either TRUE or NULL, the value is allowed.

12. Which of the statements is true regarding the table created with the following SQL statement?
CREATE TABLE autos
(vin VARCHAR2(64) primary key
,style VARCHAR2(15) default 'TUDOR'
,year char(4)
,make varchar2(12)
,model varchar2(30)
);
A. MAKE is a reserved word; the CREATE TABLE will fail.
B. The column style will always have a value.
C. There is no index on this table.
D. The column style can have a NULL value.
---
Ans: D.
A default clause ensures that the column does not contain a NULL after an insert, but not after
an update. MAKE is not a reserved word, and an index will be created on the primary key.

13. Which constraint-checking model is the default?
A. Initially immediate and deferrable
B. Initially immediate and not deferrable
C. Initially deferred and not immediately
D. Initially deferrable and not immediate
---
Ans B.
Constraints can be created as deferrable and initially deferred, but deferred constraint checking
is not the default.

14. Which statement on views is true?
A. A view can only be on one base table, although that base table can be joined to itself.
B. A view cannot be created with the same name and columns as the base table.
C. Inserts into a view are not allowed.
D. Privileges on a view can be different from those on the base table.
---
Ans: D.
Views can be created on one or more base table. Views share the same namespace as tables and
therefore cannot have the same name; columns, however, can be named the same as the base table.
SELECT, INSERT, UPDATE, and DELETE are all valid operations on a view. One of the uses for a view
is to hide portions of the base table, by granting different privileges to the view than the base table.

15. What can tablespaces be used for?
A. To organize tables and indexes into manageable groupings
B. To make sure that data stored in the tablespace does not change
C. To move data from one database to another
D. All of the above
--
Ans: D.
The primary use for a tablespace is to organize tables and indexes into manageable units.
Some of the manageable operations that you can do to a tablespace include making it read-only
or moving it from one database to another.

16. Which allocation unit is the smallest?
A. Datafile
B. Extent
C. Data block
D. Segment
--
Ans: C.
An extent is composed of two or more data blocks; a segment is composed of one or more
extents, and a datafile houses all these.


17. Which is a valid tablespace extent management specification?
A. Automatic
B. Local
C. Manual
D. Temporary
--
Ans: B.
A tablespace can have either dictionary extent management or local extent management.
B.

18. Which of the following is not a valid Oracle10g datatype?
A. timestamp with local timezone
B. binary
C. blob
D. urowid
--
Ans: B.
Although binary_float and binary_double are valid datatypes, binary is not.


19. How do you specify that a temporary table will be emptied at the end of a user’s session?
A. Create the temporary table with the ON COMMIT PRESERVE ROWS option.
B. Create the temporary table with the ON DISCONNECT PRESERVE ROWS option.
C. Create the temporary table with the ON DISCONNECT PURGE ROWS option.
D. Create the temporary table with the ON COMMIT DELETE ROWS option.
--
Ans: A. The options for temporary tables are either ON COMMIT DELETE ROWS, with causes the table to
flush at the end of each transaction, or ON COMMIT PRESERVE ROWS, which causes the table to flush
at the end of each session.

20. How can you change the comment assigned to the columns in a table?
A. Use the ALTER TABLE MODIFY COLUMN statement.
B. Use the COMMENT ON TABLE statement.
C. Use the RENAME statement.
D. Use the COMMENT ON COLUMN statement.
--
Ans: D.
You assign or change comments on a column with the COMMENT ON COLUMN statement. The
COMMENT ON TABLE statement is used to add or change the comment assigned to a table.

Saturday, April 07, 2007

Using OPatch to query inventory

servername:TOY10G > opatch lsinventory -all
Invoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0
Copyright (c) 2005, Oracle Corporation. All rights reserved..


Oracle Home : /oracle/product/10.2.0/db_1
Central Inventory : /oracle/product/oraInventory
from : /var/opt/oracle/oraInst.loc
OPatch version : 10.2.0.3.0
OUI version : 10.2.0.3.0
OUI location : /oracle/product/10.2.0/db_1/oui
Log file location :
/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/opatch2007-04-07_08-55-45
AM.log

Lsinventory Output file location :
/oracle/product/10.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2007-04-
07_08-55-45AM.txt

---------------------------------------------------------------------
List of Oracle Homes:
Name Location
ORACLE_HOME1 /oracle/product/8.1.7.4
ORACLE_HOME2 /oracle/product/9.2.0
ORACLE_HOME9206 /oracle/product/9.2.0.6
ORACLE_HOME3 /oracle/product/10.2.0/db_1
ORACLE_HOME9208 /oracle/product/9.2.0.8
agent10g /oracle/product/10.2.0/OEM/agent10g

Installed Top-level Products (2):

Oracle Database 10g
10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 2
10.2.0.3.0
There are 2 products installed in this Oracle Home.


Interim patches (3) :

Patch 5752399 : applied on Tue Jan 30 14:16:07 CST 2007
Created on 12 Jan 2007, 20:07:35 hrs US/Pacific
Bugs fixed:
5752399

Patch 5556081 : applied on Tue Jan 30 14:14:16 CST 2007
Created on 9 Nov 2006, 22:20:50 hrs PST8PDT
Bugs fixed:
5556081

Patch 5557962 : applied on Tue Jan 30 14:14:04 CST 2007
Created on 9 Nov 2006, 23:23:06 hrs PST8PDT
Bugs fixed:
4269423, 5557962, 5528974


-----------------------------------------------------------------

OPatch succeeded.

Database created 32-bit or 64-bit?

To identify whether a database was created as 32-bit or 64-bit, execute the following SQL statement:

SQL> select metadata from sys.kopm$;

If the output references the string 'B023' then it indicates that the database was created as 32-bit

If the output references the string 'B047' then it indicates that the database was created as 64-bit

NOTE: The second character is the digit zero, not an upper-case letter 'o'

sys@TOY10G> select metadata from sys.kopm$ ;

METADATA

----------------------------------------------------------------------------------------------------

0000006001240F050B0C030C0C0504050D0609070805050505050F05050505050A0505050505040506070808234723470811

23081141B0470083000107D01300000000000000000000000000000000000000000000000000000000000000000000000000

sys@GENQA> select metadata from sys.kopm$;

METADATA

----------------------------------------------------------------------------------------------------

0000006001210F050B0C030C0C0504050D06090708050F0505050F05050505050A0505050505040508234723230811230811

41B0230083002700271300000000000000000000000000000000000000000000000000000000000000000000000000000000

Friday, April 06, 2007

OCA Oracle 10g - CH2 Creating and Controlling a Database

OCA Oracle 10g - CH2 Creating and Controlling a Database:
=======================================
Review Questions

1. You need to start up the iSQL*Plus server. Which of the following
commands do you use?
A. isqlplus startup
B. isqlplusctl startup
C. isqlplusctl start
D. sqlplus start
--
Ans: C.
To use the iSQL*Plus tool, you need to start the iSQL*Plus server.
Connect to the location
where the server is going to be started, get to a command prompt, and
type isqlplusctl start. In
a Windows environment, you can start the associated service to perform
the same task.

2. You need to find the directory where the Oracle alert log is being
written. Which initialization
parameter contains this information?
A. ALERT_LOG_DEST
B. BACKGROUND_DUMP_DEST
C. LOG_DESTINATION
D. INIT_LOG_DUMP_DEST
---
Ans: B.
BACKGROUND_DUMP_DEST is the initialization parameter that determines
where the Oracle
alert log is written. This is a directory path designation.

3. An Oracle application server is an example of what component in the
Oracle Enterprise Management
Framework?
A. Managed targets
B. Application Entity
C. Destination
D. Background Object
E. None of the above
---
Ans: A.
In the Oracle Enterprise Management Framework, managed targets can be
administered
using the Enterprise Manager. Application servers are one example of a
managed target. Other
examples include databases, web servers, applications, and Oracle
agents.

4. You need to start up the Enterprise Manager Grid Control facility.
Which command should
you use?
A. agctl start agent
B. emctl startup agent
C. agctl enable agent
D. emctl startup framework
E. emctl start agent
---
Ans: E.
To use the Grid Control facility, you must start the associated agent
process.
This process can be started from a command-line prompt using the emctl
start agent command.
In a Windows environment, you can start the agent by starting the
appropriate service.

5. All the following are functional areas within the Oracle Enterprise
Management Framework
except which?
A. Repository Agent
B. Management Services
C. Database Control
D. Oracle Management Repository
E. Managed targets
--
Ans: A.
Management Services, Database Control, Oracle Management Repository, and
managed targets
are functional areas of the Oracle Enterprise Management Framework.

6. You want to view the EMP table structure from within the iSQL*Plus
interface. Which command
produces the desired output?
A. DEFINE EMP
B. SHOW EMP
C. DESCRIBE EMP
D. DISPLAY EMP
---
Ans: C.
You can use the DESCRIBE command within SQL*Plus and iSQL*Plus to
display the structure
of a table or a view. This information includes the column name, column
width, datatype,
and whether the column allows null values.

7. All the following are database management options within the Database
Configuration Assistant
except which?
A. Change Database Initialization Parameters
B. Create A Database
C. Manage Templates
D. Delete A Database
---
ANs: A. The Database Configuration Assistant lets you create databases,
manage templates, add
database options, and delete databases. Although you can change
initialization parameters
when you are defining a database, this is not one of the management
options available.

8. Which of the following is another term for the fully qualified name
of a database?
A. ORACLE SID
B. Global Database Name
C. Global identifier
D. Oracle global name
E. ORACLE ID
---
Ans: B.

The Global Database Name is another term for the fully qualified name of
a database. The
global database name is composed of the database name and database
domain.

9. Which of the following Oracle accounts is not automatically
configured by the DBCA?
A. SYS
B. SYSTEM
C. SYSMAN
D. DBSNMP
E. All the above accounts are configured automatically by DBCA.
---
Ans: E.
The DBCA creates the SYS, SYSTEM, SYSMAN, and DBSNMP accounts by
default. You can lock
the accounts and set the initial password.

10. You have worked with your systems administrator to set up predefined
disk partitions dedicated
to and controlled by Oracle for meeting your database storage
requirements. What is another
name for this type of storage?
A. File system storage
B. Oracle managed storage
C. Raw devices
D. Defined storage
E. None of the above
---
Ans: C.

Raw devices are disk partitions set up as special devices and managed by
Oracle. The underlying
operating system does not control the reading or writing of information
to these special
areas of disk.

11. Which new Oracle 10g feature provides a centralized location to
maintain and manage all the
files related to database backups?
A. Archive logging
B. Automated Storage Management
C. Flash Recovery
D. Data Guard
---
Ans: C.
The Flash Recovery feature is designed to ease configuration and
administration of all aspects
of Oracle backup and recovery. It predefines a location of disk to
centrally store files that Oracle
will use in case database recovery is needed.

12. Which of the following best describes seed templates?
A. DBCA template definitions that contain database definition
information and the actual
datafiles and redo log files
B. DBCA template definitions that contain database definition
information only
C. DBCA template definitions that contain database definition
information and the actual
datafiles
D. DBCA template definitions that contain database definition
information redo log file and
control file definitions
E. None of the above
---
ANS. A.
Seed templates are template definitions that contain database definition
information and the
actual datafiles and redo log files. Nonseed templates contain the
database definition but don't
contain the actual datafiles and redo log files.

13. You find a file on disk that has a .DJF extension. What type of
information would you expect
to be stored in the file?
A. The associated predefined redo logs and datafiles for nonseed
templates
B. The associated predefined redo logs and datafiles for seed templates
C. The associated predefined redo logs and control files for seed
templates
D. The associated predefined redo logs and control files for nonseed
templates
--
ANS: B.
Files that have a .DJF extension contain the predefined redo logs and
datafiles for seed templates.

14. Which of the following is not a valid Create A Database Template
option in the DBCA?
A. From An Existing Template
B. From An Existing Database And Don't Copy The Data
C. From An Existing Database And Copy The Structure And Data
D. From An Existing Template And Copy The Structure And Data
----
Ans: D. From the Template Management screen of the DBCA, you can create
a new template from an
existing template, create a new template from an existing database and
copy the structure only,
and create a new template from an existing database, copying the
structure and the data. You cannot
create a new template from an existing template and copy structure and
data.

15. Which of the following startup options does not perform a database
recovery?
A. STARTUP
B. STARTUP FORCE RESTRICT
C. STARTUP NOMOUNT
D. STARTUP OPEN
E. STARTUP RESTRICT
----
Ans: C.
Recovery of a database occurs when the database moves from the MOUNT
mode to the OPEN
mode. All these options attempt to start up and open the database except
for option C, which
only puts the database in NOMOUNT mode.

16. Which of the following shutdown statements does not perform a clean
shutdown?
A. SHUTDOWN ABORT
B. SHUTDOWN TRANSACTIONAL
C. SHUTDOWN
D. SHUTDOWN IMMEDIATE
E. All the above are considered clean shutdowns.
----
Ans: A.
Any time you perform a SHUTDOWN ABORT, Oracle does not perform a clean
shutdown. All
other types of shutdowns are considered clean shutdowns because Oracle
will not have to perform
recovery on a subsequent database startup.

17. You would like to export the system and limit access to only the DBA
staff during the export
process. Which of the following startup options should you use?
A. STARTUP NOMOUNT RESTRICT
B. STARTUP RESTRICT
C. STARTUP MOUNT RESTRICT
D. STARTUP MOUNT FORCE RESTRICT

Ans: B.
The STARTUP RESTRICT choice opens the database and allows only users
with RESTRICTED
database access to connect and use it.

18. You want to start up the database using a binary initialization
file. What is another name for
this file?
A. CONFIGFILE
B. PFILE
C. SPFILE
D. init_pfile.ora

Ans: C.
The SPFILE is another term for a server-side binary file that Oracle
reads when a database
startup is performed. This binary file contains all the nondefault
initialization parameters used
at startup.

19. Under normal circumstances, which of the following actions or events
is not found in the Oracle
alert log?
A. Database startup and shutdown information
B. Nondefault initialization parameters
C. ORA-00600 errors
D. New columns added to a user table
---
Ans: The Oracle alert log contains a chronological history of
administrative events and actions
and certain types of database errors that occur within the database.
Adding a column to a user
table is not an administrative action and is not recorded in the alert
log.

20. On your Unix database server, you have installed and configured a
database using the DBCA.
You need to find out what ports are being used for the various Oracle
tools. Where would you
find this information?

A. $ORACLE_HOME/bin/portlist.ini
B. $ORACLE_HOME/rdbms/admin/portlist.ini
C. $ORACLE_HOME/install/portlist.ini
D. $ORACLE_HOME/bin/portlist.ini
---
Ans
C. The $ORACLE_HOME/install/portlist.ini file contains information about
what ports are
being used by the various Oracle tools.

How to remove incarnation records from the recovery catalog

To remove incarnation records from the recovery catalog:
-------------------------------------------------------

1. Allocate a channel of type maintenance:

allocate channel for maintenance type 'disk';

2. Issue change ... delete commands to update unwanted backup pieces,
archived redo logs,
and image copies to deleted status. Issue list commands or query the
recovery catalog
views to obtain primary keys for archived redo logs, backup sets,
control file copies,
or datafile copies.

change backupset 100, 101, 102, 103 delete;

E.g. query RC_BACKUP_SET

rman@CATAPRD6> ;
1* select bs_key,completion_time from rc_backup_set where
db_id=4050733714
rman@CATAPRD6> /

BS_KEY COMPLETION_TIME
---------- --------------------
4762840 01-APR-2007 22:28:15
4762841 01-APR-2007 22:28:55
4762842 01-APR-2007 22:30:29
4762843 01-APR-2007 22:32:18
4762844 01-APR-2007 22:33:53
4762845 01-APR-2007 22:37:20


3. Release the allocated maintenance channel:

release channel;

4. Start a SQL*Plus session and connect to the recovery catalog. This
example connects
to database RCAT as user RMAN:

% sqlplus rman/rman@rcat

5. Obtain the DBINC_KEY values for the incarnations whose records you
want to delete
by querying the RC_DATABASE_INCARNATION recovery catalog view:

SQL> SELECT * FROM rc_database_incarnation;

rman@CATAPRD6> desc rc_database_incarnation;
Name Null? Type
----------------------------------------------------- --------
------------------------------------
DB_KEY NOT NULL NUMBER
DBID NOT NULL NUMBER
DBINC_KEY NOT NULL NUMBER
NAME NOT NULL
VARCHAR2(8)
RESETLOGS_CHANGE# NOT NULL NUMBER
RESETLOGS_TIME NOT NULL DATE
CURRENT_INCARNATION
VARCHAR2(3)
PARENT_DBINC_KEY NUMBER

6. Execute the following DML statement, where key_value is the value of
DBINC_KEY:

SQL> DELETE FROM dbinc WHERE dbinc_key=key_value;

RMAN will remove the specified incarnation records from the recovery
catalog.

rman@CATAPRD6> delete from dbinc where dbinc_key=4750552;

1 row deleted.

rman@CATAPRD6> commit;

RMAN> list incarnation of database GEN3Q
2> ;

RMAN-03022: compiling command: list

List of Database Incarnations
DB Key Inc Key DB Name DB ID CUR Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
4750551 4757334 GEN3Q 4050733714 NO 36172261409 31-MAR-2007
12:19:51
4750551 4760656 GEN3Q 4050733714 YES 36172261409 31-MAR-2007
22:35:06