Vous êtes sur la page 1sur 66

c 


  
  
 

The Delete command will log the data changes in the log file where as the truncate will simply
remove the data without it. Hence Data removed by Delete command can be rolled back but not
the data removed by TRUNCATE. Truncate is a DDL statement whereas DELETE is a DML
statement

c     


 
 
 !" # $
%


1000000


&%%
  
   

Yes, if you are using autonomous transactions in the Database triggers.

c 
 !'(c   
 % 

%
%  

The UTL_FILE package lets your PL/SQL programs read and write operating system (OS) text
files. It provides a restricted version of standard OS stream file input/output (I/O).
Subprogram -Description
FOPEN function-Opens a file for input or output with the default line size.
IS_OPEN function -Determines if a file handle refers to an open file.
FCLOSE procedure -Closes a file.
FCLOSE_ALL procedure -Closes all open file handles.
GET_LINE procedure -Reads a line of text from an open file.
NEW_LINE procedure-Writes one or more OS-specific line terminators to a file.
FFLUSH procedure-Physically writes all pending output to a file.
FOPEN function -Opens a file with the maximum line size specified.

c    
   
%   

Database triggers are fired whenever any database action like INSERT, UPATE, DELETE,
LOGON LOGOFF etc occurs. Form triggers on the other hand are fired in response to any event
that takes place while working with the forms, say like navigating from one field to another or
one block to another and so on.

c "($c  

OCI is Oracle Call Interface. When applications developers demand the most powerful interface
to the Oracle Database Server, they call upon the Oracle Call Interface (OCI). OCI provides the
most comprehensive access to all of the Oracle Database functionality. The newest performance,
scalability, and security features appear first in the OCI API. If you write applications for the
Oracle Database, you likely already depend on OCI. Some types of applications that depend
upon OCI are:
· PL/SQL applications executing SQL
· C++ applications using OCCI
· Java applications using the OCI-based JDBC driver
· C applications using the ODBC driver
· VB applications using the OLEDB driver
· Pro*C applications
· Distributed SQL

c  "#"#( 

A precompiler is a tool that allows programmers to embed SQL statements in high-level source
programs like C, C++, COBOL, etc. The precompiler accepts the source program as input,
translates the embedded SQL statements into standard Oracle runtime library calls, and generates
a modified source program that one can compile, link, and execute in the usual way. Examples
are the Pro*C Precompiler for C, Pro*Cobol for Cobol, SQLJ for Java etc.

c &
%  %
 % 

%
  % %
% )

Drop Procedure/Function ; yes, if they are standalone procedures or functions. If they are a part
of a package then one have to remove it from the package definition and body and recompile the
package.

What Is Oracle?

Oracle is a company. Oracle is also a database server, which manages data in a very structured
way. It allows users to store and retrieve related data in a multiuser environment so that many
users can concurrently access the same data. All this is accomplished while delivering high
performance. A database server also prevents unauthorized access and provides efficient
solutions for failure recovery.

What Is an Oracle Database?

An Oracle database is a collection of data treated as a big unit in the database server.

What Is an Oracle Instance?

Every running Oracle database is associated with an Oracle instance. When a database is started
on a database server (regardless of the type of computer), Oracle allocates a memory area called
the System Global Area (SGA) and starts one or more Oracle processes. This combination of the
SGA and the Oracle processes is called an Oracle instance. The memory and processes of an
instance manage the associated database's data efficiently and serve the one or multiple users of
the database.
What Is a Parameter File?

A parameter file is a file that contains a list of initialization parameters and a value for each
parameter. You specify initialization parameters in a parameter file that reflect your particular
installation. Oracle supports the following two types of parameter files:

˜ Server Parameter Files - Binary version. Persistent.


˜ Initialization Parameter Files - Text version. Not persistent.

What Is a Server Parameter File?

A server parameter file is a binary file that acts as a repository for initialization parameters. The
server parameter file can reside on the machine where the Oracle database server executes.
Initialization parameters stored in a server parameter file are persistent, in that any changes made
to the parameters while an instance is running can persist across instance shutdown and startup.

What Is a Initialization Parameter File?

An initialization parameter file is a text file that contains a list of initialization parameters. The
file should be written in the client's default character set. Sample initialization parameter files are
provided on the Oracle distribution medium for each operating system. A sample file is sufficient
for initial use, but you will probably want to modify the file to tune the database for best
performance. Any changes will take effect after you completely shut down and restart the
instance.

What is System Global Area (SGA)?


÷ 
        
   
        

The SGA is allocated in


       
         

memory when an Oracle database instance is started, and any change in the value will take effect
at the next startup.

What is PGA?

When you start a


The h  (Program or h  
 ' is a memory area (RAM' that stores data and control information for a single process.

user process, that process has a private RAM area, used for sorting SQL results and managing
special joins called ³hash´ joins. This private RAM is known as the Program Global Area
(PGA). Each individual PGA memory area is allocated each time a new user connects to the
database.

What Is a User Account?

A user account is defines the user's attributes AND identified by a user name, including the
following
˜ Password for database authentication
˜ Privileges and roles
˜ Default tablespace for database objects
˜ Default temporary tablespace for query processing work space

What Is the Relation of a User Account and a Schema?

User accounts and schemas have a one-to-one relation. When you create a user, you are also
implicitly creating a schema for that user. A schema is a logical container for the database
objects (such as tables, views, triggers, and so on) that the user creates. The schema name is the
same as the user name, and can be used to unambiguously refer to objects owned by the user.

What Is a User Role?

A user role is a group of privileges. Privileges are assigned to users through user roles. You
create new roles, grant privileges to the roles, and then grant roles to users.

What is a Database Schema?

A schema is a collection of logical structures of data, or schema objects. A schema is owned by a


database user and has the same name as that user. Each user owns a single schema. Schema
objects can be created and manipulated with SQL and include: tables, views, and other types of
data objects.

What Is a Database Table?

A database table is a basic unit of data logical storage in an Oracle database. Data is stored in
rows and columns. You define a table with a table name, such as employees, and a set of
columns. You give each column a column name, such as employee_id, last_name, and job_id; a
datatype, such as VARCHAR2, DATE, or NUMBER; and a width. The width can be
predetermined by the datatype, as in DATE. If columns are of the NUMBER datatype, define
precision and scale instead of width. A row is a collection of column information corresponding
to a single record.

What Is a Table Index?

Index is an optional structure associated with a table that allow SQL statements to execute more
quickly against a table.
What Is an Oracle Tablespace?

A tablespace is a logical storage unit - multiple application objects can be stored in one
tablespace. A database can contain multiple tablespaces. Each tablespace in an Oracle database
consists of one or more files called datafiles,

What Is an Oracle Data File?

An Oracle data file is a big unit of physical storage in the OS file system. One or many Oracle
data files are organized together to provide physical storage to a single Oracle tablespace.

What Is a Static Data Dictionary?

Data dictionary tables are not directly accessible, but you can access information in them through
data dictionary views. To list the data dictionary views available to you, query the view
DICTIONARY. Many data dictionary tables have three corresponding views:

˜ An ALL_ view displays all the information accessible to the current user, including
information from the current user's schema as well as information from objects in other
schemas, if the current user has access to those objects by way of grants of privileges or
roles.
˜ A DBA_ view displays all relevant information in the entire database. DBA_ views are
intended only for administrators. They can be accessed only by users with the SELECT
ANY TABLE privilege. This privilege is assigned to the DBA role when the system is
initially installed.
˜ A USER_ view displays all the information from the schema of the current user. No
special privileges are required to query these views.

What Is a Dynamic Performance View?

Dynamic performance views, or "V$" views, are useful for identifying instance-level
performance problems. All V$ views are listed in the V$FIXED_TABLE view. These views are
called dynamic performance views because they are continuously updated while a database is
open and in use, and their contents relate primarily to performance.You can select from these
views, but you can never update or alter them.

What Is a Recycle Bin?

Recycle bin is a logical storage to hold the tables that have been dropped from the database, in
case it was dropped in error. Tables in recycle bin can be recovered back into database by the
Flashback Drop action. Oracle database recycle save the same purpose as the recycle bin on your
Windows desktop.
Recycle bin can be turned on or off in the recyclebin=on/off in your parametere file.

What Is SQL*Plus?

SQL*Plus is an interactive and batch query tool that is installed with every Oracle Database
Server or Client installation. It has a command-line user interface, a Windows Graphical User
Interface (GUI) and the iSQL*Plus web-based user interface.

What Is Transport Network Substrate (TNS)?

TNS, Transport Network Substrate, is a foundation technology, built into the Oracle Net
foundation layer that works with any standard network transport protocol.

What Is Open Database Communication (ODBC)?

ODBC, Open Database Communication, a standard API (application program interface)


developed by Microsoft for Windows applications to communicate with database management
systems.

Oracle offers ODBC drivers to allow Windows applications to connect Oracle server through
ODBC.

÷     ÷


What Is an Oracle Tablespace?

An Oracle tablespace is a big unit of logical storage in an Oracle database. It is managed and
used by the Oracle server to store structures data objects, like tables and indexes.

What Is an Oracle Data File?

An Oracle data file is a big unit of physical storage in the OS file system. One or many Oracle
data files are organized together to provide physical storage to a single Oracle tablespace.

How a Tablespace Is Related to Data Files?

Each tablespace in an Oracle database consists of one or more files called datafiles, which are
physical structures that conform to the operating system in which Oracle is running.

How a Database Is Related to Tablespaces?

A database's data is collectively stored in the datafiles that constitute each tablespace of the
database. For example, the simplest Oracle database would have one tablespace and one datafile.
Another database can have three tablespaces, each consisting of two datafiles (for a total of six
datafiles).
How To View the Tablespaces in the Current Database?

If you want to get a list of all tablespaces used in the current database instance, you can use the
DBA_TABLESPACES view as shown in the following SQL script example:

ð ð ð



ð ð  

 ð  ð

ð

ð
 ð 
 ð ð 

 ð  ð



ð

ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð
"    

#" #
ð ð$"    


" 
 
ð ð"    


What Are the Predefined Tablespaces in a Database?

When you create a new database, Oracle server will create 4 required tablespaces for the new
database:

˜ SYSTEM Tablespace - Every Oracle database contains a tablespace named SYSTEM,


which Oracle creates automatically when the database is created. The SYSTEM
tablespace is always online when the database is open.
˜ SYSAUX Tablespace - The SYSAUX tablespace was installed as an auxiliary tablespace
to the SYSTEM tablespace when you created your database. Some database components
that formerly created and used separate tablespaces now occupy the SYSAUX tablespace.
˜ UNDO Tablespace - UNDO tablespaces are special tablespaces used solely for storing
undo information. You cannot create any other segment types (for example, tables or
indexes) in undo tablespaces. Each database contains zero or more undo tablespaces. In
automatic undo management mode, each Oracle instance is assigned one (and only one)
undo tablespace. Undo data is managed within an undo tablespace using undo segments
that are automatically created and maintained by Oracle.
˜ TEMP Tablespace - When the SYSTEM tablespace is locally managed, you must define
at least one default temporary tablespace when creating a database. A locally managed
SYSTEM tablespace cannot be used for default temporary storage.

How To View the Data Files in the Current Database?

If you want to get a list of all tablespaces used in the current database instance, you can use the
DBA_TABLESPACES view as shown in the following SQL script example:

ð ð ð



ð %&'%()&&**&&+, 
ð %%&**&&-, 
ð ð  

 ð  "  
ð
 ##
" ð 

 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð. $ .#
.$ .ð ð#+/0123,//
ð ð$. $ .#
.$ .ð ð$#0,+-3-00/
#. $ .#
.$ .##40-3+10/
ð ð
. $ .#
.$ .ð ð
#-2,2+210/

How To Create a new Oracle Data File?

There is no dedicated statement to create a data file. Data files are created as part of statements
that manages other data structures, like tablespace and database.

How To Create a New Tablespace?

If you want a new dataspace, you can use the CREATE TABLESPACE ... DATAFILE statement
as shown in the following script:

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð ð  

 ð  ð

ð

ð
 ð 
 ð ð 

 ð  ð



ð

ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð
"    

#" #
ð ð$"    


" 
 
ð ð"    

ð "    


ð ð  

 ð  "  
ð
 ##
" ð 

 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð. $ .#
.$ .ð ð#+/0123,//
ð ð$. $ .#
.$ .ð ð$#0,+-3-00/
#. $ .#
.$ .##40-3+10/
ð ð
. $ .#
.$ .ð ð
#-2,2+210/
ð .
. ð #+/0123,/

So one statement created two structures: a tablespace and a data file. If you check your file
system with Windows file explorer, you will see the data file is located in the \temp directory of.
The data file size is about 10MB. Its contents should be blank and full of \x00 at this time.

How To Rename a Tablespace?

You can easily rename a tablespace by using the ALTER TABLESPACE ... RENAME TO
statement as shown in the example below:
ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&  
7()& 

&'%()&&

ð ð  

 ð  ð

ð

ð
 ð 
 ð ð 

 ð  ð



ð

ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð
"    

#" #
ð ð$"    


" 
 
ð ð"    

ð "    


How To Drop a Tablespace?

If you have an existing tablespace and you don't want it anymore. You can delete a tablespace by
using the DROP TABLESPACE statement as shown in the example below:

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð #
 ð *()& 

&'%()&))

What Happens to the Data Files If a Tablespace Is Dropped?

If a tablespace is dropped, what happens to its data files? By default, data files will remain in OS
file system, even if the tablespace they are mapped is dropped. Of course, you delete the data
files using OS commands, if they are no longer needed.

Another way of deleting data files is to use the INCLUDING clause in the DROP
TABLESPACE statement. Here is a SQL sample script:

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð #
 ð *()&"#"8

ð
##
" ð 

&'%()&))

How To Create a Table in a Specific Tablespace?


After you have created a new tablespace, you can give it to your users for them to create tables in
the new tablespace. To create a table in a specific tablespace, you need to use the TABLESPACE
clause in the CREATE TABLE statement. Here is a sample script:

ð ð ð



ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 9 


ð  

 *&*
 ð *()&
ðð  
: *)%( 

&'%&

ð ð  
&'%&*&'%()&&*7*;(
 ð 
 ð
-<9  &'%()&&*=5ð ð55 ð 5> 


  


 ð   <ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  ð !
 ðð ð+/3


How To See Free Space of Each Tablespace?

One of the important DBA tasks is to watch the storage usage of all the tablespaces to make sure
there are enough free space in each tablespace for database applications to function properly.
Free space information can be monitored through the USER_FREE_SPACE view. Each record
in USER_FREE_SPACE represents an extent, a contiguous area of space, of free space in a data
file of a tablespace.

Here is SQL script example on how to see free space of a tablespace:

ð 9 


ð ð  

 ð  " "#
ð
 ð  ð 
-<9  
 ð  "=5ð ð55 ð 5> 

 ð  " "#


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð 2+/-20,11
ð ð0+/+430/+,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,
ð ð0,22-,

This tells us that:

˜ MY_SPACE has a single free extent of 10MB.


˜ USERS has one big free extent of 100MB, and many small free extents of 64KB.

How To Bring a Tablespace Offline?

If you want to stop users using a tablespace, you can bring it offline using the ALTER
TABLESPACE ... OFFLINE statement as shown in the following script:

ð 9 


ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&"   

&'%()&&%

How To Bring a Tablespace Online?

If you have brought a tablespace offline, now you want to make it available to users again, you
can use the ALTER TABLESPACE ... ONLINE statement as shown in the following script:

ð 9 

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&"   

&'%()&&%



ð 

 ð *()&" 

&'%()&&%

How To Add Another Datafile to a Tablespace?


If you created a tablespace with a data file a month ago, now 80% of the data file is used, you
should add another data file to the tablespace. This can be done by using the ALTER
TABLESPACE ... ADD DATAFILE statement. See the following sample script:

ð 9 

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&
#
" 5 *) *()&'5ð"6 2 

&'%()&&%

ð ð  

 ð  "  
ð
 ##
" ð 

 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð?. $ .#
.$ .ð ð#+/0123,//
ð ð$?. $ .#
.$ .ð ð$#0,+-3-00/
#?. $ .#
.$ .##40-3+10/
ð ð
?. $ .#
.$ .ð ð
#-2,2+210/
ð ?.
. ð #+/0123,/
ð ?.
. ð #2011/

ð ð  

 ð  " "#
ð
 ð  ð 
-<9  
 ð  "=5 ð 5> 

 ð  " "#


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ,2+33-00
ð 2+/-20,11

This script created one tablespace with two data files.

What Happens If You Lost a Data File?

After you shuting down an Oracle database, you accidently deleted a data file from the operating
system. If you try to start the database again you will get error when Oracle tries to open the
database after mounting the database. The following tutorial examples shows you what will
happen if the data file c:\temp\my_space.dbf is deleted. Oracle can still start the database
instance and mount the database. But it will fail on openning the database as shown below in a
SQL*Plus session:

(@%)%7( %A

ð ð ð
ðð ð#

ð ð


 (&(&


&%ð(*8%'&%&+//,,-4,'(
BðC+1242,'(
&&'%ðC213/000'(
#&&'&(7(-33013-,'(
7(4/1+,/'(
#&&'&(*7
!/++23?& %D&&%2!(#<
&%
!/+++/?&&%2?5?.
. ð #5

ð ð9
#< 
!/++/4?&&'&()
#&&'&((*7
 (&(E7;

How Remove Data Files befor opening a Database?

Let's say you have a corrupted data file or lost a data file. Oracle can mount the database. But it
will not open the database. What you can do is to set the bad data file as offline befor opening
the database. The tutorial exercise shows you how to set two data files offline and open the
database without them:

(@%)%7( %A

ð ð ð
ðð ð#

ð ð

 

 (&(&


&%ð(*8%'&%&+//,,-4,'(
BðC+1242,'(
&&'%ðC213/000'(
#&&'&(7(-33013-,'(
7(4/1+,/'(
#&&'&(*7

ð 
#
ð #
" 5.*).*()&'5
" # 
#&&'&(&%

ð 
#
ð #
" 5.*).*()&'5
" # 
#&&'&(&%

ð 
#
ð   
#&&'&(&%

ð %%&**&&-, 
ð %&'%()&&**&&+, 
ð ð  

 ð  "  
ð
 ##
" ð 


 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð?. $ .#
.$ .ð ð#+/0123,//
ð ð$?. $ .#
.$ .ð ð$#2/--+,01/
#?. $ .#
.$ .##40-3+10/
ð ð
?. $ .#
.$ .ð ð
#-,3//+,//
ð ?.
. ð #
ð ?.
. ð #

How To Bring a Tablespace Online?

If you have brought a tablespace offline, now you want to make it available to users again, you
can use the ALTER TABLESPACE ... ONLINE statement as shown in the following script:

ð 9 

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&"   

&'%()&&%



ð 

 ð *()&" 

&'%()&&%

How To Add Another Datafile to a Tablespace?

If you created a tablespace with a data file a month ago, now 80% of the data file is used, you
should add another data file to the tablespace. This can be done by using the ALTER
TABLESPACE ... ADD DATAFILE statement. See the following sample script:

ð 9 

ð  

 ð *()&
#
" 5 *) *()&'5ð"6 +/ 

&'%()&&

ð 

 ð *()&
#
" 5 *) *()&'5ð"6 2 

&'%()&&%

ð ð  

 ð  "  
ð
 ##
" ð 

 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð?. $ .#
.$ .ð ð#+/0123,//
ð ð$?. $ .#
.$ .ð ð$#0,+-3-00/
#?. $ .#
.$ .##40-3+10/
ð ð
?. $ .#
.$ .ð ð
#-2,2+210/
ð ?.
. ð #+/0123,/
ð ?.
. ð #2011/

ð ð  

 ð  " "#
ð
 ð  ð 
-<9  
 ð  "=5 ð 5> 

 ð  " "#


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ,2+33-00
ð 2+/-20,11

This script created one tablespace with two data files.

What Happens If You Lost a Data File?

After you shuting down an Oracle database, you accidently deleted a data file from the operating
system. If you try to start the database again you will get error when Oracle tries to open the
database after mounting the database. The following tutorial examples shows you what will
happen if the data file c:\temp\my_space.dbf is deleted. Oracle can still start the database
instance and mount the database. But it will fail on openning the database as shown below in a
SQL*Plus session:

(@%)%7( %A

ð ð ð
ðð ð#

ð ð


 (&(&


&%ð(*8%'&%&+//,,-4,'(
BðC+1242,'(
&&'%ðC213/000'(
#&&'&(7(-33013-,'(
7(4/1+,/'(
#&&'&(*7
!/++23?& %D&&%2!(#<
&%
!/+++/?&&%2?5?.
. ð #5

ð ð9
#< 
!/++/4?&&'&()
#&&'&((*7
 (&(E7;

How Remove Data Files befor opening a Database?

Let's say you have a corrupted data file or lost a data file. Oracle can mount the database. But it
will not open the database. What you can do is to set the bad data file as offline befor opening
the database. The tutorial exercise shows you how to set two data files offline and open the
database without them:

(@%)%7( %A

ð ð ð
ðð ð#

ð ð

 

 (&(&


&%ð(*8%'&%&+//,,-4,'(
BðC+1242,'(
&&'%ðC213/000'(
#&&'&(7(-33013-,'(
7(4/1+,/'(
#&&'&(*7

ð 
#
ð #
" 5.*).*()&'5
" # 
#&&'&(&%

ð 
#
ð #
" 5.*).*()&'5
" # 
#&&'&(&%

ð 
#
ð   
#&&'&(&%

ð %%&**&&-, 
ð %&'%()&&**&&+, 
ð ð  

 ð  "  
ð
 ##
" ð 


 ð  "  


ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð?. $ .#
.$ .ð ð#+/0123,//
ð ð$?. $ .#
.$ .ð ð$#2/--+,01/
#?. $ .#
.$ .##40-3+10/
ð ð
?. $ .#
.$ .ð ð
#-,3//+,//
ð ?.
. ð #
ð ?.
. ð #

How To Use Windows User to Connect to the Server?

During the installation process, 10g XE will create a special Windows user group called
ORA_DBA, and put your Windows user into this group. Any Windows users in this group can
be connected to Oracle server with SYSDBA privilege without any Oracle server user account.
This process is called connecting the server as SYSDBA with OS Authentication. Here is how to
do this with a special form of the "connect" command:

=A;EE(&*7(77((&%%+/A$ >
=&%$ E*>
.'.(&'
.'.(@%)%7( %A

ð  ðð ð#


ð @7

So if "connect" is used without user name and password, the current Windows user will be
trusted if he/she is in the ORA_DBA user group on the Windows system.
How To List All User Accounts?

User accounts can be accessed through a system view called ALL_USERS. A simple SELECT
statement can be used to get a list of all user accounts. Try the following script:

.'.(@%)%7( %A

ð ð ð



ð ð  
: ð ð 

ð  ð "# 
#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<ð//+//-2/3! !/,
<ð" ð-0/3! !/,
9--/3! !/,
#ð ð-/3! !/,
 ð1/3! !/,
$#3/3! !/,

$ð ð2/3! !/,
#ð -/3! !/,

ð ð ð//3! !/,
#"+1/3! !/,

++/3! !/,
ð ð
2/3! !/,
ð ð//3! !/,

How To Create a New User Account?

If you want to create a new user account, you can log in as SYSTEM and use the CREATE
USER command as shown in the following example:

.'.(@%)%7( %A

ð ð ð



ð  
ð # "# 
"" # F%)
G 
(&

Note that CREATE is a SQL statement, so you need to terminate it with ";". This command
creates a user called "DEV", with a password of "developer". You can test this account by log in
with DEV from SQL*Plus.

How To Change User Password?

If you want to change a user's password, you can log in as SYSTEM and use the ALTER USER
command as shown in the following example:

.'.(@%)%7( %A

ð ð ð



ð 
ð # "# 
"" # 'A 
(&%

Note that ALTER is SQL statement, so you need to terminate it with ";". This command resets
DEV's password to "beginner".

How To Delete a User Account?

If you want to delete a user account and its associated schema, you can log in as SYSTEM and
use the DROP USER command as shown in the following example:

.'.(@%)%7( %A

ð ð ð



ð #ð # ð# 
())

ð  
ð # "# 
"" # F%)
G 
(&

Note that CASCADE tells the server drop the associated schema.

What Privilege Is Needed for a User to Connect to Oracle Server?

Oracle deny connection to users who has no CREATE SESSION privilege. Try the following
tutorial exercise, you will find out how Oracle denies connection:

.'.(@%)%7( %A
ð ð ð


ð  
ð # "# 
"" # F%)
G 
(&

ð (
ð  
#  F%)
!/+/02?7(# %&D( 
ð ðð")F%A 
%A

Oracle error message is pretty clear.

How To Grant CREATE SESSION Privilege to a User?

If you want give a user the CREATE SESSION privilege, you can use the GRANT command.
The following tutorial exercise shows you how to grant DEV the privilege to connect to the
server:
.'.(@%)%7( %A
ð ð ð


ð 8
 
ð ðð"
F 
8&(7

ð (
ð  
#  F%)


How To Revoke CREATE SESSION Privilege from a User?

If you take away the CREATE SESSION privilege from a user, you can use the REVOKE
command as shown in the following example script:

.'.(@%)%7( %A
ð ð ð


ð  G  
ð ðð" F 
FD(7

ð 8
 
ð ðð"
F 
8&(7

This script restored the CREATE SESSION privilege to user "dev", so you can continue other
example scripts below.

How To Lock and Unlock a User Account?

If you want to lock a user account for a short period of time, and unlock it later, you can use the
ALTER USER ... ACCOUNT command. The following sample script shows how to use this
command:

.'.(@%)%7( %A
ð ð ð


ð 
ð F
G 
(&%

ð (
ð  
#  F%)
!1///?E&7(%D

ð (
ð ð ð


ð 
ð F
G 
(&%

ð (
ð  
#  F%)

What Privilege Is Needed for a User to Create Tables?

To be able to create tables in a user's own schema, the user needs to have the CREATE TABLE
privilege, or the CREATE ANY TABLE privilege, which is more powerful, and allows the user
to create tables in other user's schema. The following tutorial exercise gives you a good example
on CREATE TABLE privilege:

.'.(@%)%7( %A
ð  
#  F%)

ð  

 =  > 
!/+/-+?(7)F%A(

ð (
ð ð ð


ð 8
 

 
F 
8&(7

ð (
ð  
#  F%)

ð  

 =  > 
!/+42/?)F%A(&'%()&5ð ð
5

The above error message tells that user "dev" is not allowed to use the tablespace "SYSTEM".
See the next question for answers.

How To Assign a Tablespace to a Users?

When you create a new user, Oracle will assign the SYSTEM tablespace to the user by default. If
you want to change this, you can assign a different table space to a user using the ALTER USER
command. The following tutorial exercise changes user dev's default tablespace, and assigns
4MB of space to dev:

.'.(@%)%7( %A
ð  
#  F%)

ð 
ð F# 

 ð ð ð 
(&%

ð 
ð F 
0 ð ð 
(&%

ð (
ð  
#  F%)

ð  

 =  > 

&'%&

ð #
  

&'%))

ð  

 =  > 

&'%&

As you can see, "dev" can create and drop tables now. You can also let "dev" to create tables in
any tablespace without any restriction by granting him the UNLIMITED TABLESPACE system
privilege.

What Privilege Is Needed for a User to Create Views?

To be able to create views in a user's own schema, the user needs to have the CREATE VIEW
privilege, or the CREATE ANY VIEW privilege, which is more powerful, and allows the user to
create views in other user's schema. The following tutorial exercise gives you a good example on
CREATE VIEW privilege:

.'.(@%)%7( %A
ð  
#  F%)

ð  
" <F;ðð  
:  
!/+/-+?(7)F%A(

ð (
ð ð ð


ð 8
 
" <
F 
8&(7

ð (
ð  
#  F%)

ð  
" <F;ðð  
:  
;&

ð #" <F; 
;))

ð  
" <F;ðð  
:  
;&

As you can see, "dev" can create and drop views now.

What Privilege Is Needed for a User to Create Indexes?

For a user to create indexes, he/she needs the same privilege as the creating tables. Just make
sure he/she has the CREATE TABLE privilege. The following tutorial exercise gives you a good
example on creating view privilege:

.'.(@%)%7( %A
ð ð ð


ð 8
 

 
F 
8&(7

ð (
ð  
#  F%)

ð  
"# $B=> 
"B&

ð #"# $B 
"B))

ð  
"# $B=> 
"B&

This exercise assumes that you followed previous exercises in the FAQ collection.

What Privilege Is Needed for a User to Query Tables in Another Schema?

For a user to run queries (SELECT statements) on tables of someone else's schema, he/she needs
the SELECT ANY TABLE privilege. The following tutorial exercise gives you a good example
of granting "dev" to query tables in "hr" schema:

.'.(@%)%7( %A
ð  
#  F%)

ð ð  

=:> E*)%( 
!/+/-+?(7)F%A(

ð (
ð ð ð


ð 8
ð  
 
 
F 
8&(7

ð (
ð  
#  F%)

ð ð  

=:> E*)%( 

=:>
!!!!!!!!!!
+/3

As you can see, "dev" can query tables in any schema now.

You also need to remember that table name must be prefixed with the schema name (same as
owner user name).

What Privilege Is Needed for a User to Insert Rows to Tables in Another Schema?

For a user to insert rows into tables of someone else's schema, he/she needs the INSERT ANY
TABLE privilege. The following tutorial exercise gives you a good example of granting "dev" to
insert rows in "hr" schema:

.'.(@%)%7( %A
ð  
#  F%)

ð "ð 
"
EH'(
 ð=5# "55#F "(7%&533//11//> 
!/+/-+?(7)F%A(

ð (
ð ð ð


ð 8
"ð 
 
 
F 
8&(7

ð (
ð  
#  F%)

ð "ð 
"
EH'(
 ð=5# "55#F "(7%&533//11//> 
+;&

As you can see, "dev" can insert rows in any schema now. But you should be careful when
giving this privilege to a regular developer.

What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema?

For a user to delete rows from tables of someone else's schema, he/she needs the DELETE ANY
TABLE privilege. The following tutorial exercise gives you a good example of granting "dev" to
delete rows in "hr" schema:

.'.(@%)%7( %A
ð  
#  F%)

ð # 
 EH'(<9  H'I5# "5 
!/+/-+?(7)F%A(

ð (
ð ð ð


ð 8
# 
 
 
F 
8&(7

ð (
ð  
#  F%)

ð # 
 EH'(<9  H'I5# "5 
+;%

As you can see, "dev" can delete rows in any schema now. But you should be careful when
giving this privilege to a regular developer.

How To Find Out What Privileges a User Currently Has?


Privileges granted to users are listed in two system views: DBA_SYS_PRIVS, and
USER_SYS_PRIVS. You can find out what privileges a user currently has by running a query on
those views as shown in the tutorial exercise below:

.'.(@%)%7( %A
ð  
#  F%)

ð ð  
7(&*)F%A ð ð ð"ð 
ð  "" 8 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ð  
 
 
# "ð 
 
 
#  
ð ðð"
#  
" <
# # 
 
 
#  
 
 

ð (
ð ð ð


ð 8
# 
 
 
F 
8&(7

ð ð  
8
"" 8  #ð ð"ð
<9  8
I595 
8
"" 8 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 
" <
9" "
#
 ð 
9# 8 
ð ðð"
9 
#
ð "G
9 
ð   
9 
ð ðð"
9# 8  # 
9
ð ðð"
9 
ð  

Looks like "hr" has move privileges than "dev".

How To Create an Oracle Database?

There are two ways to create a new database:

˜ Use the Database Configuration Assistant (DBCA) to create a database interactively.


˜ Use the CREATE DATABASE statement to create a database manually.

How To Create an Oracle Database Manually?

Based on Oracle's Administrator Guide, there are 11 steps to create a database with the CREATE
DATABASE statement:

˜ Step 1: Decide on Your Instance Identifier (SID)


˜ Step 2: Establish the Database Administrator Authentication Method
˜ Step 3: Create the Initialization Parameter File
˜ Step 4: Connect to the Instance
˜ Step 5: Create a Server Parameter File (Recommended)
˜ Step 6: Start the Instance
˜ Step 7: Issue the CREATE DATABASE Statement
˜ Step 8: Create Additional Tablespaces
˜ Step 9: Run Scripts to Build Data Dictionary Views
˜ Step 10: Run Scripts to Install Additional Options (Optional)
˜ Step 11: Back Up the Database.

Other items in this FAQ collection will follow those steps to help you creating a new database
manually from beginning to end.

How To Select an Oracle System ID (SID)?

This is Step 1. If you are planning to create a new database, you need to select an Oracle System
ID (SID). This ID will be used to identify the new Oracle database and its Oracle instance. SID
must be unique if you want to run multiple databases on a single server.

Let's set SID for the new database to be: FYI.

How To Establish Administrator Authentication to the Server?

This is Step 2. There are two ways to establish administrator authentication to a new database.

˜ Use a password file.


˜ Use operating system (OS) authentication.

Using OS authentication is easier on Windows system. If you used your own Windows user
account to install Oracle server, it will put your Windows user account into a special Window's
user group called SYSDBA. This Window's user group will be fully trusted by Oracle server
with SYSDBA privilege.

To continue with other steps, make sure you logged into the Windows system with a user
account in the SYSDBA group.

How To Create an Initialization Parameter File?

This is Step 3. To run an Oracle database as an Oracle instance, you need to create an
initialization parameter file, which contains a set of initialization parameters.

The easiest way to create an initialization parameter file to copy from the sample file provided by
Oracle. You can do this in a command window as shown below:

J 9 

).A.()(.&.&&'&(. "&

.&&'&(. "&
=)%&$ ' ">

In this example, only the SID is changed from XE to FYI. All other parameters are maintained as
is.

How To Connect the Oracle Server as SYSDBA?

This is Step 4. The best way to connect to the Oracle server as an administrator is to use
SQL*Plus. You need to run SQL*Plus with /nolog option and use the CONNECT with blank
user name, blank password and AS SYSDBA option. Here is a sample session:

J 9 
.'.(@%)%7( %A

ð  
 ðð ð#


How To Create a Server Parameter File?

This is Step 5. The initialization parameter file is good to get an Oracle database instance started.
But it is not ideal run an instance as production. You need to convert the initialization parameter
file into a Server Parameter File (SPFile) using the CREATE SPFILE statement. The script
below shows you how do this:

ð  
ð" IJ 9 '( ð"  "&
 " IJ 9 &&'&(  "& 
%&

Note that $ORACLE_HOME should be replaced by the real path name where your Oracle server
is intalled.

The SPFile should be located in the expected directory and named as SPFILE($SID).ora.

How To Start an Oracle Instance?

This is Step 6. Now you are ready to start the new Oracle Instance without any database. This
instance will be used to create a database. Starting an instance without database can be done by
using STARTUP NOMOUNT statement as shown below:

.'.(@%)%7( %A

ð  
 ðð ð#


ð ð9
#<
 (&(E7;

ð ð

 

!//1+?ð)F&%7(A&&A+, ((*&%%
('&%&(/ 

The SHUTDOWN command is need to bring the default instance XE down.

The STARTUP NOMOUNT command failed because it tried to start the default instance XE,
and there is a bad parameter in the XE instance SPFile.

See the next FAQ question to find another way to start the new instance FYI.

How To Start a Specific Oracle Instance?

A simple way to start a specific Oracle instance is to start the instance with the PFILE option as
shown in the following example:

.'.(@%)%7( %A

ð  
 ðð ð#


ð ð

 

" IJ 9 &&'&(  "&

!/331?&*AFE%A(F&%

The PFILE option allows you to specify the initialization parameter file of a specific Oracle
instance. But the initialization parameter file created in Step 3 has some problem with the log
directory.

How To Start Instance with a Minimal Initialization Parameter File?

The sample initialization parameter file provided by Oracle seems to be not working. But we can
try to start the new instance with a minimal initialization parameter file (PFile). First you can
create another PFile, $ORACLE_HOME/database/initFYI_ini_min.ora, as shown below:

'&*I "
%%(I=K.&%B.&&&. ".%'K>
7*&&A*I


Then start the FYI instance again:

ð  
 ðð ð#


ð ð

 

" IJ 9 &&'&(  "*&

 (&(&


&%ð(*8%'&%&++-0,/1'(
BðC+1,/1'(
&&'%ðC213/-3'(
#&&'&(7(2/--+,01'(
7(4/1+,/'(

How To Run CREATE DATABASE Statement?

This is Step 7. Oracle Administrator Guide provided a sample CREATE DATABASE statement.
But it is a long statement. You can modify and same it in a file,
$ORACLE_HOME/configscripts/create_database_fyi.sql, and run the file within SQL*Plus.
Here is a copy of the modified CREATE DATABASE statement:

 
#
ð  "
ð ð ð"# 
"" # 
ð ð ð
"# 
"" # 
8" 8+=5 &%B &&&  " /+%A5>ð"6 +/ 
8=5 &%B &&&  " /%A5>ð"6 +/ 
8-=5 &%B &&&  " /-%A5>ð"6 +/ 
$8" ð2
$8  ð2
$89"ð
 +
$#
" ð+//
$"ð
 ð+
9
ð
ð3ð""

"9
ð
+,
+,
#
" 5 &%B &&&  " ((*/+'5ð"6 -  ð 
$

 8 

ð ð$#
" 5 &%B &&&  " ((&7B/+'5ð"6 -  ð 
# 

 ð '(+
# 

 
 ð *)(+

" 5 &%B &&&  " *)/+'5ð"6 /  ð 
#
 ð 7'(
#
" 5 &%B &&&  " 7'(/+'5
ð"6 /  ð 
 $
# $ð"6 " "
# 

Here is how to run this long CREATE DATABASE statement:

ð LJ 9 .A.()(.&&&'&((@% 


 
#
ð  "
:
&%+?
!/+2/+? 
#
ð &%
!////?%%7%'&
!///?%%?5?. $ .#
. ".
#5
!3/0/?%&7&'%&%
ð#!/0//?7&'%)%
 ð! ?=ð->
E((*&E)&E()

Don't worry about the error messages. They are caused by the missing directory for data files in
file system.
How To Do Clean Up If CREATE DATABASE Failed?

To better organize data files, you should create a dedicated directory for each Oracle database.
This can be done by using Windows file explorer to create the \oraclexe\oradata\fyi\ directory.
Try the CREATE DATABASE statement again, when you have the directory ready.

If your CREATE DATABASE statement failed half way again, you may have to clean up the
partial result of the CREATE DATABASE statement. Here is a list of suggestions for you:

˜ Run SHUTDOWN command to stop the partial started database instance.


˜ Remove all files in FYI directory: \oraclexe\oradata\fyi\
˜ Run STARTUP NOMOUNT PFILE command to start the empty instance again to be
ready for CREATE DATABASE statement.

How To Run CREATE DATABASE Statement Again?

After cleaning up the results of a previously failed CREATE DATABASE statement, you can
run the CREATE DATABASE statement again as shown below:

ð LJ 9 .A.()(.&&&'&((@% 


 
#
ð  "
:
&%+?
!/+/4? (&*&#(

Something went wrong again. This time it might related the limitation that Oracle 10g XE only
supports one database instance. With the default instance called "XE" already defined, creating
another database instance might be not allowed.

How To Create Additional Tablespaces for an New Database?

This is Step 8. Creating additional tablespaces can be done by using the CREATE
TABLESPACE statement as shown in the following sample script:

ð  

 ð 7((
#
" 5 &%B &&&  " 7((/+'5ð"6 +/ 

ð  

 ð B
#
" 5 &%B &&&  " B/+'5ð"6 +/ 

How To Build Data Dictionary View an New Database?

This is Step 9. The Oracle Administrator Guide suggests to run two SQL scripts provided by
Oracle as shown bellow:

ð L 7/+ &% '*( &* &&%A(@%



ð L 7/+ &% '*( &* &)(@%

What Is the Simplest Tool to Run Commands on Oracle Servers?

The simplest tool to connect to an Oracle server and run commands to manage data is SQL*Plus.
It is an Oracle database client tool that works as a command-line user interface to the database
server. SQL*Plus allows you:

˜ Format, perform calculations on, store, and print from query results.
˜ Examine table and object definitions.
˜ Develop and run batch scripts.
˜ Perform database administration.

What Is the Quickest Way to Export a Table to a Flat File?

The quickest way to export a table to a flat file is probably to use the SQL*Plus SPOOL
command. It allows you to record SELECT query result to a text file on the operating system.
The following tutorial exercise shows you how control the output format, start the spooler, and
dump all record from a table to a flat text file:

*D.&%B.(
(@%)%7( %A

ð 9 

ð ð
9 #"8 
ð ð
 #G 
ð ð
" ð"6 +/// 
ð ð.&%B.(.*)%(B 
ð ð  
:   ð 

ð ð 

You should get all records in employees.txt with fixed length fields.

How To Export Data with a Field Delimiter?

The previous exercise allows you to export data with fixed field lengths. If you want export data
with variable field lengths and field delimiters, you can concatenate your fields with an
expression in the SELECT clause as shown in the tutorial exercise bellow:

ð ð
9 #"8 
ð ð
 #G 
ð ð
" ð"6 +/// 
ð ð.&%B.(.%D(B 
ð ð  
MM55MM7%MM55MM(MM55MM7(
MM55MM& %D( 

ð ð 

You should see all records in fyi_links.txt with ',' delimited fields as shown here:
+/+*ð((++3!  !/,
++/*ð((++3!  !/,

What Is SQL*Loader?

SQL*Loader is a database tool that allows to load data from external files into database tables.
SQL*Loader is available as part of the free Oracle 10g Expression Edition. It has some
interesting features as:

˜ Can load data from multiple data files into multiple tables in one load session.
˜ Can specify character set of the data.
˜ Can generate sophisticated error reports.
˜ Can load data directly to Oracle datafiles, bypassing normal record inserting process.

What Is a SQL*Loader Control File?

A SQL*Loader control file a text that defines how data files should be loaded into the database.
It allows you to specify:

˜ Where is the input data file.


˜ The format of the input date file.
˜ The target table where the data should be loaded.
˜ How input data fields should be mapped to target table columns.
˜ Select criteria to select input records for loading.
˜ Where to output errors.

How To Load Data with SQL*Loader?

Let's say you have a table defined as:

 

 (7=  =2>"  G 
(&*9=1/>

%&(&*9=1/>

'E&#


(&%7*'9=1/>"  
> 

There is an input data file stored at \oraclexe\text\student.txt with the following records:

+ðFGA+3!N!332+2+-02,3
&GEE&+!ð !342+2+-02,1
-B#9&&+-!N!1-2+2+-02,4
0%B&97%/-!N!1/24/0-02,3
27 (+!  !1+24/0-02,1
,#&F7(2!N!1324/0-02,4
3&%%&&'&%%&/2! !1124/0-02,/
1#&&C/3! !1424/0-22,3
4&8'A+3!8!102+2+002,4
+/#&%&F+,!8!102+2+00+,4
You can create a control file at \oraclexe\test\student.ctl as:

##

 #"

 ð
# 

" #ð
 "
# 55
=(&*%&(&*'E&(&%7*'>

When you are ready to load data, you can run the SQL*Loader with the "sqlldr" command:

.&%B.&)).&%.)7.+//.(F."
(@%%7(IE 
%I.&%B.(.(7%
&&I.&%B.(.(7B
%AI.&%B.(.(7%A

ð :&?%&(+//+/!
**)&E!%A&%7+/

To see details of the loading process, you should check the log file \oraclexe\test\student.log.

What Is an External Table?

An external table is a table defined in the database with data stored outside the database. Data of
an external table is stored in files on the operating systems. Accessing data of external tables are
done through data access drivers. Currently, Oracle supports two data access drivers:
ORACLE_LOADER and ORACLE_DATAPUMP.

External tables can be used to load data from external files into database, or unload data from
database to external files.

How To Load Data through External Tables?

If you have data stored in external files, you can load it to database through an external table by
the steps below:

˜ Create an external table with columns matching data fields in the external file.
˜ Create a regular table with the same columns.
˜ Run an INSERT INTO ... SELECT statement to load data from the external file to the
regular table through the external table.

What Are the Restrictions on External Table Columns?

When creating external table columns, you need to watch out some restrictions:

˜ "PRIMARY KEY" is not allowed.


˜ "NOT NULL" is not allowed.
˜ "DEFAULT value" is not allowed.
What Is a Directory Object?

A directory object is a logical alias for a physical directory path name on the operating system.
Directory objects can be created, dropped, and granted access permissions to different users. The
following tutorial exercise shows you some good examples:

(@%)%7( %A

ð ð ð


ð  
#" 
 (ð5 &%B (5 
#&

ð 8
 ##" 
 (
E 
8&(7

ð 8
<"
#" 
 (
E 
8&(7

ð  
#" 
 *)ð5 &%B *)5 
#&

ð ##" 
 *) 
#))

How To Define an External Table with a Text File?

You can use the CREATE TABLE statement to create external tables. But you need to use
ORGANIZATION EXTERNAL clause to specify the external file location and the data access
driver. The tutorial exercise below shows you how to define an external table as a text file:

(@%)%7( %A

ð 9 

ð  

 B%D(=
  =0>
7%9=+,>
(9=+,>
7(  =0>
&#

>8"6
" $
=

  # 
# 
#" 
 (

"=5B%D(B5>
> 

&'%&

ð ð  
&'%&*&'%()&&*7*;(
 ð 
 ð 

  


 ð   <ð
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 8"ðð ð0

"ðð ð-
# 

ðð ð3
Nðð ð+4
 ðð ð+/3
N9"ð
 ð ð+/
 ""Gðð ð
$
 ""Gð

" ð2

How To Run Queries on External Tables?

If you have an external table defined as a text file with the ORACLE_LOADER driver, you can
add data to the text file, and query the text file through the external table. By default, data fields
in the text file should be terminated by ','. The tutorial exercise below shows you how add data to
the external table defined in the previous exercise:

 &%B ( B%D(B


++/+'&DO+11/3!  !/,
+++/FDO11/3!  !/,

(@%)%7( %A

ð 9 

ð ð  
: B%D( 
"#
ð
ð 
#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
++/+'&DO+11/3!  !/,
+++/FDO11/3!  !/,

How To Load Data from External Tables to Regular Tables?

Once you have your data entered in a text file, and an external table defined to this text file, you
can easily load data from this text file to a regular table. The following tutorial exercise shows
you how to load data from the text file and the external table defined in the previous exercises to
a regular table:

ð  

 %D(=
  =0>"  G 
7%9=+,>

(9=+,>
7(  =0>
&#
# 
=((&>
> 

ð "ð 
"
%D(ð  
: B%D( 
;(&

ð ð  
: %D( 
"#
ð
ð 
#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+/+*ð((+/3!  !/,
++/*ð((+/3!  !/,
++/+'&DO+11/3!  !/,
+++/FDO11/3!  !/,

What Is the Data Pump Export Utility?

Oracle Data Pump Export utility is a standalone programs that allows you to export data objects
from Oracle database to operating system files called dump file set, which can be imported back
to Oracle database only by Oracle Data Pump Import utility.

The dump file set can be imported on the same system or it can be moved to another system and
loaded there.

The dump file set is made up of one or more disk files that contain table data, database object
metadata, and control information. The files are written in a proprietary, binary format. During
an import operation, the Data Pump Import utility uses these files to locate each database object
in the dump file set. Because the dump files are written by the server, rather than by the client,
the data base administrator (DBA) must create directory objects.

What Is the Data Pump Import Utility?

Oracle Data Pump Import utility is a standalone programs that allows you to import data objects
from an Oracle dump file set into Oracle database. Oracle dump file set is written in a proprietary
binary format by the Data Pump Export utility.

Import can also be used to load a target database directly from a source database with no
intervening dump files. This allows export and import operations to run concurrently,
minimizing total elapsed time. This is known as a network import. Data Pump Import enables
you to specify whether a job should move a subset of the data and metadata from the dump file
set or the source database (in the case of a network import), as determined by the import mode.
This is done using data filters and metadata filters, which are implemented through Import
commands.

How To Invoke the Data Pump Export Utility?

The Data Pump Export utility is distributed as executable file called "expdp.exe". To invoke this
utility, you should go to the "bin" directory of your Oracle server installation and run the "expdp"
command. Here is tutorial exercise on how to invoke the export utility:

.&%B.&)).&%.)7.+//.(F."

B))E%)I
B)?%&(+//+/!


E#&&7*)B)7%)F(&*E&(*
&(A&&'H(';&%&&'&((
E
7%(FD;EE%%;A**&?

 B&*)%?B))( A#" 
 I*)
# " I(*)

7&%E; B)7('AE5B))5
**&%%;'F&7()&&*(?

*&?B))G <#IF&%7
G <#I=F&%7+F&%7F&%7>

 B&*)%?B))( A# " I(*)
#" 
 I*)
ð9 ðI(
 ðI=
+?+
+?>

ð "#*7('E()&&*E**&%

G;#()=#&7%>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


9&EB(AH'A

9PIH'&*
  ðð"7(C7*)%(;EF&%
D;F&%7(&?=
#
 >& 
#" 
 #'H'7(7*)%(
# " ((&7*)%(=B)&*)>
ð9Gðð7((((((&)(E'&D
 B)&&'&(=>
9 #()%&9%)*((&A(=>


How To Invoke the Data Pump Import Utitlity?

The Data Pump Import utility is distributed as executable file called "impdp.exe". To invoke this
utility, you should go to the "bin" directory of your Oracle server installation and run the
"impdp" command. Here is tutorial exercise on how to invoke the import utility:

.&%B.&)).&%.)7.+//.(F."

*))E%)I
"*)?%&(+//+/!


E#&&7*)"*)7%)F(&*E&(*
&(A&&'H(';&%&&'&((
E
7%(FD;EE%%;A**&?

 B&*)%?*))( A#" 
 I*)
# " I(*)

7&%E;"*)7('AE5*))5
**&%%;'F&7()&&*(

*&?*))G <#IF&%7
G <#I=F&%7+F&%7F&%7>

 B&*)%?*))( A#" 
 I*)
# " I(*)

ð "#*7('E()&&*E**&%

G;#()=#&7%>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


9&EB(AH'A

9PIH'&*Q
#" 
 #'H'7(7*)%A
# " (7*)%(*)*=B)&*)>
"*)FEA*(7= >
9 #()%&E%)*((&A(=>


What Are Data Pump Export and Import Modes?

Data pump export and import modes are used to determine the type and portions of database to
be exported and imported. Oracle 10g supports 5 export and import modes:

˜ Full: Exports and imports a full database. Use the FULL parameter to specify this mode.
˜ Schema: Enables you to export and import all objects that belong to a schema. Use the
SCHEMAS parameter to specify this mode. This is the default mode.
˜ Table: Enables you to export and import specific tables and partitions. Use the TABLES
parameter to specify this mode.
˜ Tablespace: Enables a privileged user to move a set of tablespaces from one Oracle
database to another. Use the TABLESPACES parameter to specify this mode.
˜ Tablespace: Enables a privileged user to move metadata from the tables within a
specified set of tablespaces from one Oracle database to another. Use the
TRANSPORT_TABLESPACES parameter to specify this mode.

How To Estimate Disk Space Needed for an Export Job?

If you just want to know how much disk space for the dump without actually exporting any data,
you can use the ESTIMATE_ONLY=y parameter on the expdp command. The following tutorial
exercise shows you how a system user wants to see the disk space estimates on a full database
export:

.&%B.&)).&%.)7.+//.(F."

B))ð ð
I ð
" 
 I
ð&AKð ð
KKð ð $
/+K?ð ð
::::I
 ð
" 
 I

(*&)A((7(AGð*E
((A'H#
ð  $
ð9 

 #

(*&K<ð//+//KK<<<8 8ðK0 
(*&K<ð//+//KK<<<ð
"
ðK3 
(*&K<ð//+//KK<<<ð
 ðð"8K+, 

(*&Kð ð
KKð ð#
" K/G
(*&K
ð ð ðKKððJK/G

&%(*&7(AGð*E?+,41 
N'Kð ð
KKð ð $
/+K(7((7%%*)%
Now you know that you need 170 MB disk space to export the entire data base.

Oracle also records the screen output in a log file called export.log at
\oraclexe\app\oracle\admin\XE\dpdump.

How To Do a Full Database Export?

If you are ready to do a full database export, you can use the FULL=y parameter on the expdp
command, as shown in the following tutorial exercise:

B))ð ð
I ð
" 
 I
ð&AKð ð
KKð ð $
/+K?ð ð
::::I
(*&)A((7(AGð*E
((A'H#
ð  $
ð9 

 #


&%(*&7(AGð*E?+,41 
((A'H)#
ð  $

 ð 
((A'H)#
ð  $
ð ðð  ð 
((A'H)#
ð  $
ð9  ð 

B)<ð//+//<<<8 8ð-2+ 
B)<ð//+//<<<ð
"
ð+,1 
B)<ð//+//<<<ð
 ðð"8+++3 

&(&'%Kð ð
KKð ð $
/+K7%&
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#7*)%(ð ð
ð ð $
/+(?
?. $ .. .# ".$ .## . $#
# 
N'Kð ð
KKð ð $
/+K(7((7%%*)%

Where Is the Export Dump File Located?

If you are not specifying the dump directory and file name, the dump file will be stored in the
default dump directory with the default file name. The tutorial exercise below tells you find what
is your default dump directory and locate the dump file.

(@%)%7( %A

ð ð ð


ð ; 
1 
ð &* 
+, 
ð )&E 
0/ 
ð ð  
: '&( 
< #" 
  #" 
 
9
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ð ð#
 #".&%B.&)).&%.&*.$ .)7*).
ð ð
ð
#" &%B (
ð ð #".&%B.&)).&%.)7.+//.
(F.'.%
Obviously, the default dump directory is directory object defined to
\oraclexe\app\oracle\admin\XE\dpdump\. If you go to that directory, you will find the full
database dump file is called "expdat.dmp".

How To Export Your Own Schema?

If you have a non-system user account and you want to export all data objects in the schema
associated with your account, you can use the "expdp" command with the SCHEMAS parameter.
Running "expdp" command with a non-system user account requires a directory object granted to
this user account. The following tutorial exercise shows you how to define a directory object and
export a schema:

*D.&%B.E7*)

.&%B.&)).&%.)7.+//.(F."

(@%)%7( %A
ð ð ð


ð  
#" 
 E7*)ð5.&%B.E7*)5 
#&

ð 8
 ##" 
 E7*)
E 
8&(7

ð 8
<"
#" 
 E7*)
E 
8&(7

ð @7

B))E ð9 ðIE
#" 
 IE7*)# " I(E*&*)8" I(E*&%A

ð&AK9KKð ð $
ð9 /+K?
E ::::::::ð9 ðIE#" 
 IE7*)
# " I(E*&*)
8" I(E*&%A
(*&)A((7(AGð*E
((A'H)ð9  $


 #


&%(*&7(AGð*E?4,/G
((A'H)ð9  $
 ð9  
ð9
((A'H)ð9  $
ð   ð   
((A'H)ð9  $


 

B)K9KK
" ðK,/12G2;(
B)K9KK# 

ðK,,-G3;(
B)K9KK  ðK+23,G+/3;(
B)K9KK  ð
K+21,G+/3;(

&(&'%K9KKð ð $
ð9 /+K%& 7%&
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#7*)%(9ð ð $
ð9 /+(?
?. $ .9# .ð9 # 
N'K9KKð ð $
ð9 /+K(7((7%%*)%
How To Export Several Tables Together?

If you don't want to export the entire schema and only want to export several tables only, you can
use the "expdp" command with the "TABLES" parameter as shown in the following tutorial
exercise:

.&%B.&)).&%.)7.+//.(F."

B))E 
 ðI*)%()&*(
#" 
 IE7*)# " I&'%(*)8" I&'%(%A

ð&AK9KKð ð $

 /+K?E ::::::::

 ðI*)%()&*(#" 
 IE7*)
# " I&'%(*)
8" I&'%(%A
(*&)A((7(AGð*E
((A'H)
  $


 #


&%(*&7(AGð*E?+1G
((A'H)
  $


 
((A'H)
  $

 "# $ "# $
((A'H)
  $

 ð
"

((A'H)
  $

 "# $ ð


"
((A'H)
  $

  

((A'H)
  $

 ð
"
 
((A'H)
  $


"88 
((A'H)
  $

 ð


"ð

B)K9KK# 

ðK,,-G3;(
B)K9KK  ðK+23,G+/3;(
&(&'%K9KKð ð $

 /+K%& 7%&
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#7*)%(9ð ð $

 /+(?
?. $ .9# .
 ð# 
N'K9KKð ð $

 /+K(7((7%%*)%

What Happens If the Imported Table Already Exists?

If the import process tries to import a table that already exists, the Data Pump Import utility will
return an error and skip this table. The following exercise shows you a good example:

.&%B.&)).&%.)7.+//.(F."
*))E 
 ðI*)%(
#" 
 IE7*)# " I&'%(*)8" I&'%(%A

&(&'%K9KKð ð" 

 /+K%& 7%&
ð&AK9KKð ð" 

 /+K?E ::
 ðI*)%(
#" 
 IE7*)# " I&'%(*)8" I&'%(%A
((A'H)
  $


 
!-4+2+?
&'%K9KK  ðKB((%%)
*&&&&&&;%%'(D))7&'%B((&
(D)
((A'H)
  $


 #

((A'H)
  $

 "# $ "# $

How To Import One Table Back from a Dump File?

If you only want to import one table back to the database, you can use a dump file that was
created by full export, schema export or a table export. The following tutorial exercise shows
you how to import the "fyi_links" table from a dump file created by a schema export:

.&%B.&)).&%.)7.+//.(F."

(@%)%7( %A
ð 9 

ð #
 %D( 

&'%))

ð B 

*))E 
 ðI%D(#" 
 IE7*)
# " I(E*&*)8" I&'%(%A

&(&'%K9KKð ð" 

 /+K%& 7%&
ð&AK9KKð ð" 

 /+K?E ::
 ðI%D(
#" 
 IE7*)# " I(E*&*)8" I&'%(%A
((A'H)ð9  $


 
((A'H)ð9  $


 #

*)K9KK ""GðK,-32G0;(
((A'H)ð9  $

 ð
"

((A'H)ð9  $

 "# $ ð


"
((A'H)ð9  $

 ð


"ð

N'K9KKð ð" 

 /+K(7((7%%*)%

What Are the Original Export and Import Utilities?

Oracle original Export and Import utilities are standalone programs that provide you a simple
way for you to transfer data objects between Oracle databases, even if they reside on platforms
with different hardware and software configurations.

When you run Export against an Oracle database, objects (such as tables) are extracted, followed
by their related objects (such as indexes, comments, and grants), if any. The extracted data is
written to an export dump file. The Import utility reads the object definitions and table data from
the dump file.

An export file is an Oracle binary-format dump file that is typically located on disk or tape. The
dump files can be transferred using FTP or physically transported (in the case of tape) to a
different site. The files can then be used with the Import utility to transfer data between
databases that are on systems not connected through a network. The files can also be used as
backups in addition to normal backup procedures.

Export and Import utilities are now being replaced by Data Pump Export and Import utilities in
Oracle 10g. But you can still use them.
How To Invoke the Original Export Import Utilities?

If you really want to run the original export import utilities, you can still go to "bin" directory of
the Oracle server path and run the "exp" or "imp" command. The tutorial exercise below tells
you how to run the export and import utilities in help modes:

.&%B.&)).&%.)7.+//.(F."

B)E%)I
7&% B))*)7)&&*('AE
$**&%%;'77(&* )&((;?

 B&*)%? $ð


"8 

7&%E; B)7('AE $
**&%%;'F&7(&A7*(
())&&*(
77(?

*&? $G <#IF&%7
G <#I=F&%7+F&%7F&%7>

 B&*)%? $ð


"8 8
ðI 
 ðI= # 
 8>

 ðI=
+?+
+?>
+()&
&'%


*)E%)I


What Is Open Database Communication (ODBC)?

ODBC, Open Database Communication, a standard API (application program interface)


developed by Microsoft for Windows applications to communicate with database management
systems.

Oracle offers ODBC drivers to allow Windows applications to connect Oracle server through
ODBC.

How To Install Oracle ODBC Drivers?

Oracle offers different ODBC drivers for different versions of Oracle servers. When you install
an Oracle server or a client tools on your Windows system, the appropriate ODBC driver will be
installed for you automatically.

If you want to install a specific ODBC driver, you need to go to


http://www.oracle.com/technology/software/tech/windows/odbc/index.html. Download the right
ODBC driver and follow the instructions to install it.
How To Find Out What Oracle ODBC Drivers Are Installed?

To find out what Oracle ODBC drivers are installed on your Windows system, you can use the
ODBC manager to look at them:

˜ Go to Control Panel.
˜ Go to Administrative Tools.
˜ Run Data Sources (ODBC).
˜ Go to System DSN tab.
˜ Click the Add button.

You should a list of all ODBC drivers installed on your system. Oracle ODBC drivers should be
on the list. For example, your installed ODBC driver list could look like the one the picture
bellow with two Oracle ODBC drivers, "Oracle in OraClient10g_home1" and "Oracle in XE":

How Can Windows Applications Connect to Oracle Servers?

A Windows application can connect to an Oracle server directly, if it knows how to use the
Oracle TNS technology.

A Windows application can connect to an Oracle server indirectly through Windows ODBC
manager, becaused offers ODBC drivers to support the ODBC API. The diagram below shows
how MS Access can connect to an Oracle server through the ODBC driver:

How To Create Tables for ODBC Connection Testing?

If you want to follow the tutorial exercises in the sections below, you need to create a user
account and a table for ODBC connection testing as shown here:

ð  
((* 


ð  
ð "# 
"" # 
G 
(&

ð 8
 
ð ðð"
 
8&(7

ð 8
 

 
 
8&(7

ð 
ð # 

 ð ð ð 
(&%

ð 
ð F 
0 ð ð 
(&%

ð   


ð  

 F&@=  > 
ð "ð 
"
F&@ ð=-> 
ð "ð 
"
F&@ ð=2> 
ð "ð 
"
F&@ ð=3> 

How To Check the Oracle TNS Settings?

If you have installed an Oracle server or an Oracle client tool on your local system, the TNS is
automatically installed with a simple configuration file, tnsnames.ora, to define Oracle connect
identifiers.
For example, if you have Oracle XE server installed, you will have the tnsnames.ora located at
\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN. It should contain a connect
identifier called XE defined as:

$ I
=# ð"
"I
=## ððI
=
I
>=9ð
I%&%E(>
=
I+2+>
>
= 
#
I
=ð  I# #"
#>
=ð "  I$ >
>
>

How To Define a Data Source Name (DSN) in ODBC Manager?

DSN (Data Source Name) is an ODBC connection identifier for Windows applications. Here is
how you can define a DSN on your Windows system:

˜ Go to Control Panel.
˜ Go to Administrative Tools.
˜ Run Data Sources (ODBC).
˜ Go to System DSN tab.
˜ Click the Add button.
˜ Select the "Oracle in XE" driver.
˜ Enter Data Source Name: FYI_DSN.
˜ Enter Description: FYIcenter DSN Oracle Setting.
˜ Enter TNS Service Name: XE.
˜ Click the Test Connection button.
˜ Enter User Name: fyi.
˜ Enter Password: retneciyf.
˜ Click the OK button.

You should see a "Connection successful" as shown in the following picture:


How To Connect MS Access to Oracle Servers?

Once you got a DSN defined in the ODBC manager that connects to an Oracle server, you can
connect a normal MS Access document to the Oracle server, and link an Access table to Oracle
table. The tutorial below gives you a good example:

˜ Start MS Access with a new database file.


˜ Go to File menu.
˜ Select Get External Data.
˜ Select Import.... The Import dialog box shows up.
˜ Select Files of type: ODBC Database(). The Select Data Source dialog box shows up.
˜ Click the Machine Data Source tab. You should see the DSN name "FYI_DSN" you
defined earlier.
˜ Select "FYI_DSN".
˜ Enter User Name: fyi.
˜ Enter Password: retneciyf.

You should see the Oracle ODBC Driver Connect dialog box as shown in the picture below:

                     !  "#   " 
      $   #    $%

How To Connect ASP Pages to Oracle Servers?

If you are running Windows IIS Web server and serving ASP Web pages, you can get data from
Oracle servers into your ASP pages through ODBC drivers. To do this, you need to install the
correct Oracle ODBC driver and define a DSN on the IIS Web server.

Then you can use ADODB objects to connect to the Oracle server over the ODBC driver in your
ASP pages. The tutorial example below gives you a good example:

V 
ðIðF&'H=K##K>
)K#ðI "#ð "#I <#IK
ððI B7=Kð  
: F&@K>
()(;=KV)#&&*&%(FF&#?K>
()(;=KV)K>
#<E%
ð 
()(<=ð=K"#K>RF'%>
ð FB
)
()(;=KV )K>
ð%(
%(




1. Give one method for transferring a table from one schema to another:

Level:Intermediate

Expected Answer: There are several possible methods, export-import, CREATE TABLE... AS
SELECT, or COPY.

2. What is the purpose of the IMPORT option IGNORE? What is it's default setting?

Level: Low

Expected Answer: The IMPORT IGNORE option tells import to ignore "already exists" errors. If
it is not specified the tables that already exist will be skipped. If it is specified, the error is
ignored and the tables data will be inserted. The default value is N.

3. You have a rollback segment in a version 7.2 database that has expanded beyond optimal, how
can it be restored to optimal?

Level: Low

Expected answer: Use the ALTER TABLESPACE ..... SHRINK command.

4. If the DEFAULT and TEMPORARY tablespace clauses are left out of a CREATE USER
command what happens? Is this bad or good? Why?

Level: Low

Expected answer: The user is assigned the SYSTEM tablespace as a default and temporary
tablespace. This is bad because it causes user objects and temporary segments to be placed into
the SYSTEM tablespace resulting in fragmentation and improper table placement (only data
dictionary objects and the system rollback segment should be in SYSTEM).
5. What are some of the Oracle provided packages that DBAs should be aware of? Level:
Intermediate to High

Expected answer: Oracle provides a number of packages in the form of the DBMS_ packages
owned by the SYS user. The packages used by DBAs may include: DBMS_SHARED_POOL,
DBMS_UTILITY, DBMS_SQL, DBMS_DDL, DBMS_SESSION, DBMS_OUTPUT and
DBMS_SNAPSHOT. They may also try to answer with the UTL*.SQL or CAT*.SQL series of
SQL procedures. These can be viewed as extra credit but aren?t part of the answer.

6. What happens if the constraint name is left out of a constraint clause?

Level: Low

Expected answer: The Oracle system will use the default name of SYS_Cxxxx where xxxx is a
system generated number. This is bad since it makes tracking which table the constraint belongs
to or what the constraint does harder.

7. What happens if a tablespace clause is left off of a primary key constraint clause?

Level: Low

Expected answer: This results in the index that is automatically generated being placed in then
users default tablespace. Since this will usually be the same tablespace as the table is being
created in, this can cause serious performance problems.

8. What is the proper method for disabling and re-enabling a primary key constraint?

Level: Intermediate

Expected answer: You use the ALTER TABLE command for both. However, for the enable
clause you must specify the USING INDEX and TABLESPACE clause for primary keys.

9. What happens if a primary key constraint is disabled and then enabled without fully specifying
the index clause?

Level: Intermediate

Expected answer: The index is created in the user?s default tablespace and all sizing information
is lost. Oracle doesn?t store this information as a part of the constraint definition, but only as part
of the index definition, when the constraint was disabled the index was dropped and the
information is gone.

10. (On UNIX) When should more than one DB writer process be used? How many should be
used?

Level: High
Expected answer: If the UNIX system being used is capable of asynchronous IO then only one is
required, if the system is not capable of asynchronous IO then up to twice the number of disks
used by Oracle number of DB writers should be specified by use of the db_writers initialization
parameter.

11. You are using hot backup without being in archivelog mode, can you recover in the event of
a failure? Why or why not?

Level: High

Expected answer: You can't use hot backup without being in archivelog mode. So no, you
couldn't recover.

12. What causes the "snapshot too old" error? How can this be prevented or mitigated?

Level: Intermediate

Expected answer: This is caused by large or long running transactions that have either wrapped
onto their own rollback space or have had another transaction write on part of their rollback
space. This can be prevented or mitigated by breaking the transaction into a set of smaller
transactions or increasing the size of the rollback segments and their extents.

13. How can you tell if a database object is invalid?

Level: Low

Expected answer: By checking the STATUS column of the DBA_, ALL_ or USER_OBJECTS
views, depending upon whether you own or only have permission on the view or are using a
DBA account.

14. A user is getting an ORA-00942 error yet you know you have granted them permission on
the table, what else should you check?

Level: Low

Expected answer: You need to check that the user has specified the full name of the object
(SELECT empid FROM scott.emp; instead of SELECT empid FROM emp;) or has a synonym
that points to the object (CREATE SYNONYM emp FOR scott.emp;)

15. A developer is trying to create a view and the database won?t let him. He has the
"DEVELOPER" role which has the "CREATE VIEW" system privilege and SELECT grants on
the tables he is using, what is the problem? Level: Intermediate Expected answer: You need to
verify the developer has direct grants on all tables used in the view. You can't create a stored
object with grants given through a role.
16. If you have an example table, what is the best way to get sizing data for the production table
implementation?

Level: Intermediate

Expected answer: The best way is to analyze the table and then use the data provided in the
DBA_TABLES view to get the average row length and other pertinent data for the calculation.
The quick and dirty way is to look at the number of blocks the table is actually using and ratio
the number of rows in the table to its number of blocks against the number of expected rows.

17. How can you find out how many users are currently logged into the database? How can you
find their operating system id?

Level: high Expected answer: There are several ways. One is to look at the v$session or
v$process views. Another way is to check the current_logins parameter in the v$sysstat view.
Another if you are on UNIX is to do a "ps -ef|grep oracle|wc -l? command, but this only works
against a single instance installation.

18. A user selects from a sequence and gets back two values, his select is:

SELECT pk_seq.nextval FROM dual; What is the problem?

Level: Intermediate

Expected answer: Somehow two values have been inserted into the dual table. This table is a
single row, single column table that should only have one value in it.

19. How can you determine if an index needs to be dropped and rebuilt?

Level: Intermediate

Expected answer: Run the ANALYZE INDEX command on the index to validate its structure
and then calculate the ratio of LF_BLK_LEN/LF_BLK_LEN+BR_BLK_LEN and if it isn?t near
1.0 (i.e. greater than 0.7 or so) then the index should be rebuilt. Or if the ratio BR_BLK_LEN/
LF_BLK_LEN+BR_BLK_LEN is nearing 0.3.

(
))%
*%
 %


1. Define OFA.

Level: Low

Expected answer: OFA stands for Optimal Flexible Architecture. It is a method of placing
directories and files in an Oracle system so that you get the maximum flexibility for future tuning
and file placement.
2. How do you set up your tablespace on installation? Level: Low

Expected answer: The answer here should show an understanding of separation of redo and
rollback, data and indexes and isolation os SYSTEM tables from other tables. An example would
be to specify that at least 7 disks should be used for an Oracle installation so that you can place
SYSTEM tablespace on one, redo logs on two (mirrored redo logs) the TEMPORARY
tablespace on another, ROLLBACK tablespace on another and still have two for DATA and
INDEXES. They should indicate how they will handle archive logs and exports as well. As long
as they have a logical plan for combining or further separation more or less disks can be
specified.

3. What should be done prior to installing Oracle (for the OS and the disks)?

Level: Low

Expected Answer: adjust kernel parameters or OS tuning parameters in accordance with


installation guide. Be sure enough contiguous disk space is available.

4. You have installed Oracle and you are now setting up the actual instance. You have been
waiting an hour for the initialization script to finish, what should you check first to determine if
there is a problem?

Level: Intermediate to high

Expected Answer: Check to make sure that the archiver isn?t stuck. If archive logging is turned
on during install a large number of logs will be created. This can fill up your archive log
destination causing Oracle to stop to wait for more space.

5. When configuring SQLNET on the server what files must be set up?

Level: Intermediate

Expected answer: INITIALIZATION file, TNSNAMES.ORA file, SQLNET.ORA file

6. When configuring SQLNET on the client what files need to be set up?

Level: Intermediate

Expected answer: SQLNET.ORA, TNSNAMES.ORA

7. What must be installed with ODBC on the client in order for it to work with Oracle?

Level: Intermediate

Expected answer: SQLNET and PROTOCOL (for example: TCPIP adapter) layers of the
transport programs.
8. You have just started a new instance with a large SGA on a busy existing server. Performance
is terrible, what should you check for?

Level: Intermediate

Expected answer: The first thing to check with a large SGA is that it isn?t being swapped out.

9. What OS user should be used for the first part of an Oracle installation (on UNIX)?

Level: low

Expected answer: You must use root first.

10. When should the default values for Oracle initialization parameters be used as is?

Level: Low

Expected answer: Never

11. How many control files should you have? Where should they be located?

Level: Low

Expected answer: At least 2 on separate disk spindles. Be sure they say on separate disks, not
just file systems.

12. How many redo logs should you have and how should they be configured for maximum
recoverability?

Level: Intermediate

Expected answer: You should have at least three groups of two redo logs with the two logs each
on a separate disk spindle (mirrored by Oracle). The redo logs should not be on raw devices on
UNIX if it can be avoided.

13. You have a simple application with no "hot" tables (i.e. uniform IO and access requirements).
How many disks should you have assuming standard layout for SYSTEM, USER, TEMP and
ROLLBACK tablespaces?

Expected answer: At least 7, see disk configuration answer above.

(+

1. How can you determine the space left in a file system?

Level: Low Expected answer: There are several commands to do this: du, df, or bdf
2. How can you determine the number of SQLNET users logged in to the UNIX system? Level:
Intermediate Expected answer: SQLNET users will show up with a process unique name that
begins with oracle, if you do a ps -ef|grep oracle|wc -l you can get a count of the number of
users.

3. What command is used to type files to the screen? Level: Low Expected answer: cat, more, pg

4. What command is used to remove a file? Level: Low Expected answer: rm

5. Can you remove an open file under UNIX? Level: Low Expected answer: yes

6. How do you create a decision tree in a shell script? Level: intermediate Expected answer:
depending on shell, usually a case-esac or an if-endif or fi structure

7. What is the purpose of the grep command? Level: Low Expected answer: grep is a string
search command that parses the specified string from the specified file or files

8. The system has a program that always includes the word nocomp in its name, how can you
determine the number of processes that are using this program? Level: intermediate Expected
answer: ps -ef|grep *nocomp*|wc -l

9. What is an inode? Level: Intermediate Expected answer: an inode is a file status indicator. It is
stored in both disk and memory and tracts file status. There is one inode for each file on the
system.

10. The system administrator tells you that the system hasn?t been rebooted in 6 months, should
he be proud of this? Level: High Expected answer: Maybe. Some UNIX systems don?t clean up
well after themselves. Inode problems and dead user processes can accumulate causing possible
performance and corruption problems. Most UNIX systems should have a scheduled periodic
reboot so file systems can be checked and cleaned and dead or zombie processes cleared out.

11. What is redirection and how is it used? Level: Intermediate Expected answer: redirection is
the process by which input or output to or from a process is redirected to another process. This
can be done using the pipe symbol "|", the greater than symbol ">" or the "tee" command. This is
one of the strengths of UNIX allowing the output from one command to be redirected directly
into the input of another command.

12. How can you find dead processes? Level: Intermediate Expected answer: ps -ef|grep zombie
-- or -- who -d depending on the system.

13. How can you find all the processes on your system? Level: Low Expected answer: Use the ps
command

14. How can you find your id on a system? Level: Low Expected answer: Use the "who am i"
command.
15. What is the finger command? Level: Low Expected answer: The finger command uses data
in the passwd file to give information on system users.

16. What is the easiest method to create a file on UNIX? Level: Low Expected answer: Use the
touch command

17. What does >> do? Level: Intermediate Expected answer: The ">>" redirection symbol
appends the output from the command specified into the file specified. The file must already
have been created.

18. If you aren?t sure what command does a particular UNIX function what is the best way to
determine the command? Expected answer: The UNIX man -k command will search the man
pages for the value specified. Review the results from the command to find the command of
interest.

—,

" ) % ) %%




1. How can you determine if an Oracle instance is up from the operating system level? Level:
Low Expected answer: There are several base Oracle processes that will be running on multi-
user operating systems, these will be smon, pmon, dbwr and lgwr. Any answer that has them
using their operating system process showing feature to check for these is acceptable. For
example, on UNIX a ps -ef|grep pmon will show what instances are up.

2. Users from the PC clients are getting messages indicating : Level: Low ORA-06114: (Cnct
err, can't get err txt. See Servr Msgs & Codes Manual) What could the problem be? Expected
answer: The instance name is probably incorrect in their connection string.

3. Users from the PC clients are getting the following error stack: Level: Low ERROR: ORA-
01034: ORACLE not available ORA-07318: smsget: open error when opening sgadef.dbf file.
HP-UX Error: 2: No such file or directory What is the probable cause? Expected answer: The
Oracle instance is shutdown that they are trying to access, restart the instance.

4. How can you determine if the SQLNET process is running for SQLNET V1? How about V2?
Level: Low Expected answer: For SQLNET V1 check for the existence of the orasrv process.
You can use the command "tcpctl status" to get a full status of the V1 TCPIP server, other
protocols have similar command formats. For SQLNET V2 check for the presence of the
LISTENER process(s) or you can issue the command "lsnrctl status".

5. What file will give you Oracle instance status information? Where is it located? Level: Low
Expected answer: The alert.ora log. It is located in the directory specified by the
background_dump_dest parameter in the v$parameter table.

6. Users aren?t being allowed on the system. The following message is received: Level:
Intermediate ORA-00257 archiver is stuck. Connect internal only, until freed What is the
problem? Expected answer: The archive destination is probably full, backup the archive logs and
remove them and the archiver will re-start.

7. Where would you look to find out if a redo log was corrupted assuming you are using Oracle
mirrored redo logs? Level: Intermediate Expected answer: There is no message that comes to the
SQLDBA or SRVMGR programs during startup in this situation, you must check the alert.log
file for this information.

8. You attempt to add a datafile and get: Level: Intermediate ORA-01118: cannot add anymore
datafiles: limit of 40 exceeded What is the problem and how can you fix it? Expected answer:
When the database was created the db_files parameter in the initialization file was set to 40. You
can shutdown and reset this to a higher value, up to the value of MAX_DATAFILES as specified
at database creation. If the MAX_DATAFILES is set to low, you will have to rebuild the control
file to increase it before proceeding.

9. You look at your fragmentation report and see that smon hasn?t coalesced any of you
tablespaces, even though you know several have large chunks of contiguous free extents. What is
the problem? Level: High Expected answer: Check the dba_tablespaces view for the value of
pct_increase for the tablespaces. If pct_increase is zero, smon will not coalesce their free space.

10. Your users get the following error: Level: Intermediate ORA-00055 maximum number of
DML locks exceeded What is the problem and how do you fix it? Expected answer: The number
of DML Locks is set by the initialization parameter DML_LOCKS. If this value is set to low
(which it is by default) you will get this error. Increase the value of DML_LOCKS. If you are
sure that this is just a temporary problem, you can have them wait and then try again later and the
error should clear.

11. You get a call from you backup DBA while you are on vacation. He has corrupted all of the
control files while playing with the ALTER DATABASE BACKUP CONTROLFILE command.
What do you do?

Level: High Expected answer: As long as all datafiles are safe and he was successful with the
BACKUP controlfile command you can do the following: CONNECT INTERNAL STARTUP
MOUNT (Take any read-only tablespaces offline before next step ALTER DATABASE
DATAFILE .... OFFLINE;) RECOVER DATABASE USING BACKUP CONTROLFILE
ALTER DATABASE OPEN RESETLOGS; (bring read-only tablespaces back online) Shutdown
and backup the system, then restart If they have a recent output file from the ALTER
DATABASE BACKUP CONTROL FILE TO TRACE; command, they can use that to recover
as well. If no backup of the control file is available then the following will be required:
CONNECT INTERNAL STARTUP NOMOUNT CREATE CONTROL FILE .....; However,
they will need to know all of the datafiles, logfiles, and settings for MAXLOGFILES,
MAXLOGMEMBERS, MAXLOGHISTORY, MAXDATAFILES for the database to use the
command
þ  

        

What is RAC?
RAC stands for Real Application cluster. It is a clustering solution from Oracle Corporation that
ensures high availability of databases by providing instance failover, media failover features.
Mention the Oracle RAC software components:-
Oracle RAC is composed of two or more database instances. They are composed of Memory
structures and background processes same as the single instance database.Oracle RAC instances
use two processes GES(Global Enqueue Service), GCS(Global Cache Service) that enable cache
fusion.Oracle RAC instances are composed of following background processes:
ACMS²Atomic Controlfile to Memory Service (ACMS)
GTX0-j²Global Transaction Process
LMON²Global Enqueue Service Monitor
LMD²Global Enqueue Service Daemon
LMS²Global Cache Service Process
LCK0²Instance Enqueue Process
RMSn²Oracle RAC Management Processes (RMSn)
RSMN²Remote Slave Monitor

What is GRD?
GRD stands for Global Resource Directory. The GES and GCS maintains records of the statuses
of each datafile and each cahed block using global resource directory.This process is referred to
as cache fusion and helps in data integrity.
Give Details on Cache Fusion:-
Oracle RAC is composed of two or more instances. When a block of data is read from datafile by
an instance within the cluster and another instance is in need of the same block,it is easy to get
the block image from the insatnce which has the block in its SGA rather than reading from the
disk. To enable inter instance communication Oracle RAC makes use of interconnects. The
Global Enqueue Service(GES) monitors and Instance enqueue process manages the cahce fusion.
Give Details on ACMS:-
ACMS stands for Atomic Controlfile Memory Service.In an Oracle RAC environment ACMS is
an agent that ensures a distributed SGA memory update(ie)SGA updates are globally committed
on success or globally aborted in event of a failure.
Give details on GTX0-j :-
The process provides transparent support for XA global transactions in a RAC environment.The
database autotunes the number of these processes based on the workload of XA global
transactions.
Give details on LMON:-
This process monitors global enques and resources across the cluster and performs global
enqueue recovery operations.This is called as Global Enqueue Service Monitor.
Give details on LMD:-
This process is called as global enqueue service daemon. This process manages incoming
remote resource requests within each instance.
Give details on LMS:-
This process is called as Global Cache service process.This process maintains statuses of
datafiles and each cahed block by recording information in a Global Resource
Dectory(GRD).This process also controls the flow of messages to remote instances and manages
global data block access and transmits block images between the buffer caches of different
instances.This processing is a part of cache fusion feature.
Give details on LCK0:-
This process is called as Instance enqueue process.This process manages non-cache fusion
resource requests such as libry and row cache requests.
Give details on RMSn:-
This process is called as Oracle RAC management process.These pocesses perform managability
tasks for Oracle RAC.Tasks include creation of resources related Oracle RAC when new
instances are added to the cluster.
Give details on RSMN:-
This process is called as Remote Slave Monitor.This process manages background slave process
creation andd communication on remote instances. This is a background slave process.This
process performs tasks on behalf of a co-ordinating process running in another instance.

What components in RAC must reside in shared storage?


All datafiles, controlfiles, SPFIles, redo log files must reside on cluster-aware shred storage.

What is the significance of using cluster-aware shared storage in an Oracle RAC environment?
All instances of an Oracle RAC can access all the datafiles,control files, SPFILE's, redolog files

when these files are hosted out of cluster-aware shared storage which are group of shared disks.
Give few examples for solutions that support cluster storage:-
ASM(automatic storage management),raw disk devices,network file system(NFS), OCFS2 and
OCFS(Oracle Cluster Fie systems).

What is an interconnect network?


an interconnect network is a private network that connects all of the servers in a cluster. The
interconnect network uses a switch/multiple switches that only the nodes in the cluster can
access.

How can we configure the cluster interconnect?


Configure User Datagram Protocol(UDP) on Gigabit ethernet for cluster interconnect.On unia
and linux systems we use UDP and RDS(Reliable data socket) protocols to be used by Oracle
Clusterware.Windows clusters use the TCP protocol.

Can we use crossover cables with Oracle Clusterware interconnects?


No, crossover cables are not supported with Oracle Clusterware intercnects.
What is the use of cluster interconnect?
Cluster interconnect is used by the Cache fusion for inter instance communication.

How do users connect to database in an Oracle RAC environment?


Users can access a RAC database using a client/server configuration or through one or more
middle tiers ,with or without connection pooling.Users can use oracle services feature to connect
to database.

What is the use of a service in Oracle RAC environemnt?


Applications should use the services feature to connect to the Oracle database.Services enable us
to define rules and characteristics to control how users and applications connect to database
instances.

What are the characteriscs controlled by Oracle services feature?


The charateristics include a unique name, workload balancing and failover options,and high
availability characteristics.

Which enable the load balancing of applications in RAC?


Oracle Net Services enable the load balancing of application connections across all of the
instances in an Oracle RAC database.

What is a virtual IP address or VIP?


A virtl IP address or VIP is an alternate IP address that the client connectins use instead of the
standard public IP address. To configureVIP address, we need to reserve a spare IP address for
each node, and the IP addresses must use the same subnet as the public network.

What is the use of VIP?


If a node fails, then the node's VIP address fails over to another node on which the VIP address
can accept TCP connections but it cannot accept Oracle connections.
Give situations under which VIP address failover happens:-
VIP addresses failover happens when the node on which the VIP address runs fails, all interfaces
for the VIP address fails, all interfaces for the VIP address are disconnected from the network.

What is the significance of VIP address failover?


When a VIP address failover happens, Clients that attempt to connect to the VIP address receive
a rapid connection refused error .They don't have to wait for TCP connection timeout messages.
What are the administrative tools used for Oracle RAC environments?
Oracle RAC cluster can be administered as a single image using OEM(Enterprise
Manager),SQL*PLUS,Servercontrol(SRVCTL),clusterverificationutility(cvu),DBCA,NETCA

How do we verify that RAC instances are running?


Issue the following query from any one node connecting through SQL*PLUS.
$connect sys/sys as sysdba
SQL>select * from V$ACTIVE_INSTANCES;
The query gives the instance number under INST_NUMBER column,host_:instancename under
INST_NAME column.

What is FAN?
Fast application Notification as it abbreviates to FAN relates to the events related to
instances,services and nodes.This is a notification mechanism that Oracle RAc uses to notify
other processes about the configuration and service level information that includes service status
changes such as,UP or DOWN events.Applications can respond to FAN events and take
immediate action.

Where can we apply FAN UP and DOWN events?


FAN UP and FAN DOWN events can be applied to instances,services and nodes.

State the use of FAN events in case of a cluster configuration change?


During times of cluster configuration changes,Oracle RAC high availability framework
publishes a FAN event immediately when a state change occurs in the cluster.So applications can
receive FAN events and react immediately.This prevents applications from polling database and
detecting a problem after such a state change.

Why should we have seperate homes for ASm instance?


It is a good practice to have ASM home seperate from the database hom(ORACLE_HOME).This
helps in upgrading and patching ASM and the Oracle database software independent of each
other.Also,we can deinstall the Oracle database software independent of the ASM instance.

What is the advantage of using ASM?


Having ASM is the Oracle recommended storage option for RAC databases as the ASM
maximizes performance by managing the storage configuration across the disks.ASM does this
by distributing the database file across all of the available storage within our cluster database
environment.
What is rolling upgrade?
It is a new ASM feature from Database 11g.ASM instances in Oracle database 11g release(from
11.1) can be upgraded or patched using rolling upgrade feature. This enables us to patch or
upgrade ASM nodes in a clustered environment without affecting database availability.During a
rolling upgrade we can maintain a functional cluster while one or more of the nodes in the cluster
are running in different software versions.

Can rolling upgrade be used to upgrade from 10g to 11g database?


No,it can be used only for Oracle database 11g releases(from 11.1).

State the initialization parameters that must have same value for every instance in an Oracle
RAC database:-
Some initialization parameters are critical at the database creation time and must have same
values.Their value must be specified in SPFILE or PFILE for every instance.The list of
parameters that must be identical on every instance are given below:
ACTIVE_INSTANCE_COUNT
ARCHIVE_LAG_TARGET
COMPATIBLE
CLUSTER_DATABASE
CLUSTER_DATABASE_INSTANCE
CONTROL_FILES
DB_BLOCK_SIZE
DB_DOMAIN
DB_FILES
DB_NAME
DB_RECOVERY_FILE_DEST
DB_RECOVERY_FILE_DEST_SIZE
DB_UNIQUE_NAME
INSTANCE_TYPE (RDBMS or ASM)
PARALLEL_MAX_SERVERS
REMOTE_LOGIN_PASSWORD_FILE
UNDO_MANAGEMENT
Can the DML_LOCKS and RESULT_CACHE_MAX_SIZE be identical on all instances?
These parameters can be identical on all instances only if these parameter values are set to zero.
What two parameters must be set at the time of starting up an ASM instance in a RAC
environment?The parameters CLUSTER_DATABASE and INSTANCE_TYPE must be set.
Mention the components of Oracle clusterware:-
Oracle clusterware is made up of components like voting disk and Oracle Cluster
Registry(OCR). What is a CRS resource?
Oracle clusterware is used to manage high-availability operations in a cluster.Anything that
Oracle Clusterware manages is known as a CRS resource.Some examples of CRS resources are
database,an instance,a service,a listener,a VIP address,an application process etc.
What is the use of OCR?
Oracle clusterware manages CRS resources based on the configuration information of CRS
resources stored in OCR(Oracle Cluster Registry).

How does a Oracle Clusterware manage CRS resources?


Oracle clusterware manages CRS resources based on the configuration information of CRS
resources stored in OCR(Oracle Cluster Registry).

Name some Oracle clusterware tools and their uses?


OIFCFG - allocating and deallocating network interfaces
OCRCONFIG - Command-line tool for managing Oracle Cluster Registry
OCRDUMP - Identify the interconnect being used
CVU - Cluster verification utility to get status of CRS resources

What are the modes of deleting instances from ORacle Real Application cluster Databases?
We can delete instances using silent mode or interactive mode using DBCA(Database
Configuration Assistant).

How do we remove ASM from a Oracle RAC environment?


We need to stop and delete the instance in the node first in interactive or silent mode.After that
asm can be removed using srvctl tool as follows:
srvctl stop asm -n node_name
srvctl remove asm -n node_name
We can verify if ASM has been removed by issuing the following command:
srvctl config asm -n node_name

How do we verify that an instance has been removed from OCR after deleting an instance?
Issue the following srvctl command:
srvctl config database -d database_name
cd CRS_HOME/bin
./crs_stat

How do we verify an existing current backup of OCR?


We can verify the current backup of OCR using the following command : ocrconfig -
showbackup

What are the performance views in an Oracle RAC environment?


We have v$ views that are instance specific. In addition we have GV$ views called as global
views that has an INST_ID column of numeric data type.GV$ views obtain information from
individual V$ views.
What are the types of connection load-balancing?
There are two types of connection load-balancing:server-side load balancing and client-side load
balancing.

What is the differnece between server-side and client-side connection load balancing?
Client-side balancing happens at client side where load balancing is done using listener.In case
of server-side load balancing listener uses a load-balancing advisory to redirect connections to
the instance providing best service.
Give the usage of srvctl:-
srvctl start instance -d db_name -i "inst_name_list" [-o start_options]srvctl stop instance -d name
-i "inst_name_list" [-o stop_options]srvctl stop instance -d orcl -i "orcl3,orcl4" -o
immediatesrvctl start database -d name [-o start_options]srvctl stop database -d name [-o
stop_options]srvctl start database -d orcl -o mount

þ     


     
 
  !

Oracle dataguard 11g is the latest high availability solution from Oracle Corporation.It uses the
concept of primary database and one or more standby databases to provide high
availability.Basic mechanism behind standby database configuration is the Redo Transport
Services, wherein redo data is shipped from Primary database to one or more standby databases.

http://neworacledba.blogspot.com/2009/10/oracle-dataguard-11g-redo-transport_16.html

A comprehensive set of Oracle dataguard processes help in redo shipping.Some important


processes are :

1) Log Network Server (LNS) - Runs on primary database. It reads the redo information directly
from redo log buffer in SGA and ships it to standby databases with the help of Oracle Net
Services

2) RFS (Remote File Server) - This is the LNS counterpart at standby database site. It recevies
the redo information sent by LNS and writes them to standby Redo Log File (SRL)

Depending on method in which redo transport services work, there are two types of redo
transport services :

1) Synchronous Redo Transport (SYNC). Also known as zero data loss

2) Asynchronous redo transport (ASYNC)

We'll be discussing about synchronous redo transport(SYNC)/zero data loss in detail in this post.

1) Whenever an user commits a transaction, corresponding redo vectors are written from redo
log buffer in SGA to online redo log file using the process LGWR (Log Writer).
2) At the same time Log Network Server (LNS) reads the redo information from redo log buffer
in SGA and ships it to standby sites with the help of Oracle Net Services.

3) Remote File Server (RFS) process at the standby site receives the information sent by LNS
from primary database site and writes them to standby redo log files (SRL).

Both Linux and Solaris are flavours of UNIX. Solaris is the form of unix customized by Sun
Microsystems. It is now acquired by Oracle Corporation. Linux is an open source. It is now
being customized by many different companies like ORacle Corporation,Red Hat, SuSe, Debian
etc. Some unix commands are common to both linux and solaris whereas some commands differ.

Linux is a freeware and some vendors like fedora core offer linux whichcan be downloaded and
installed for free.

Solaris is licenced version from sun microsystems (can be fixed or floating licence).

Both are operating systems upon which all the applications run.

Sun has its own form of hardware called as sun servers which are used to host solaris.

Check the documentation of the vendor before installing linux to confirm the compatability of
linux in the particular hardware.

There are many open source forms and groups that helps us information on linux.

 " ""
 ##

From Oracle database 11g, ASMCMD has COpy option included to it.It is used to copy database
files into and out of ASM diskgroups in local system or an remote system.ASMCMD copy
command can be used to transfer files. It doesn't require an active database instance.Following
files can be transferred using ASMCMD Copy Command :

1) Data files

2) archived redo log files

3) password file

4) Initialization parameter file

http://neworacledba.blogspot.com/2009/10/oracle-asm-automatic-storage-manager_22.html

Usage :

cp - ifr connect_string:source_filename connect_string:targetfilename


Where options are,

i - Interactive copy. Prompt before copying or overwriting the file

f - If the destination file already exists, remove it and try again without user interaction

r - recursive copy. Same as normal copy command. Copies all subdirectories

source_filename - Source file name. It can be fully qualified filename(full path), an ASM alias

target_filename - target file name

target_directory - target directory

connection_string - connection string used in case of remote instance copy. Not needed for local
system. It is of form host:port. In case of local system port number is 1521

þ     


     
 
  !

Oracle dataguard 11g is the latest high availability solution from Oracle Corporation.It uses the
concept of primary database and one or more standby databases to provide high
availability.Basic mechanism behind standby database configuration is the Redo Transport
Services, wherein redo data is shipped from Primary database to one or more standby databases.

http://neworacledba.blogspot.com/2009/10/oracle-dataguard-11g-redo-transport_16.html

A comprehensive set of Oracle dataguard processes help in redo shipping.Some important


processes are :

1) Log Network Server (LNS) - Runs on primary database. It reads the redo information directly
from redo log buffer in SGA and ships it to standby databases with the help of Oracle Net
Services

2) RFS (Remote File Server) - This is the LNS counterpart at standby database site. It recevies
the redo information sent by LNS and writes them to standby Redo Log File (SRL)

Depending on method in which redo transport services work, there are two types of redo
transport services :

1) Synchronous Redo Transport (SYNC). Also known as zero data loss

2) Asynchronous redo transport (ASYNC)

We'll be discussing about synchronous redo transport(SYNC)/zero data loss in detail in this post.
1) Whenever an user commits a transaction, corresponding redo vectors are written from redo
log buffer in SGA to online redo log file using the process LGWR (Log Writer).

2) At the same time Log Network Server (LNS) reads the redo information from redo log buffer
in SGA and ships it to standby sites with the help of Oracle Net Services.

3) Remote File Server (RFS) process at the standby site receives the information sent by LNS
from primary database site and writes them to standby redo log files (SRL).

For full story read :

http://neworacledba.blogspot.com/2009/10/oracle-dataguard-11g-redo-transport_16.html

Vous aimerez peut-être aussi