Showing posts with label DB. Show all posts
Showing posts with label DB. Show all posts

Sunday, February 12, 2017

RMAN recovery using until SCN

Recovering the DB after the clone.


SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/app/database/dev/data01/system01.dbf'

SQL> recover database using backup controlfile;
ORA-00279: change 461885697981 generated at 02/03/2017 15:39:21 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_113_934902581.dbf
ORA-00280: change 461885697981 for thread 1 is in sequence #113


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00308: cannot open archived log
'/app/database/dev/archive_logs/1_113_934902581.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log
'/app/database/dev/archive_logs/1_113_934902581.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3


Check whether we have the required archives in the backup.

RMAN> list backuppiece '/app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hlrrm59a_1_1_196149.rman';


List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
74      74      1   1   AVAILABLE   DISK        /app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hlrrm59a_1_1_196149.rman


RMAN> list backupset 74;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
74      2.95M      DISK        00:00:01     03-FEB-17
        BP Key: 74   Status: AVAILABLE  Compressed: YES  Tag: TAG20170203T201850
        Piece Name: /app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hlrrm59a_1_1_196149.rman

  List of Archived Logs in backup set 74
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    114     461885718790 03-FEB-17 461885734590 03-FEB-17


We don't have the file requried i.e. 113. Get it from the tapes and apply.
 

SQL> recover database using backup controlfile;
ORA-00279: change 461885697981 generated at 02/03/2017 15:39:21 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_113_934902581.dbf
ORA-00280: change 461885697981 for thread 1 is in sequence #113


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 461885718790 generated at 02/03/2017 17:00:22 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_114_934902581.dbf
ORA-00280: change 461885718790 for thread 1 is in sequence #114
ORA-00278: log file '/app/database/dev/archive_logs/1_113_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885734590 generated at 02/03/2017 18:00:20 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_115_934902581.dbf
ORA-00280: change 461885734590 for thread 1 is in sequence #115
ORA-00278: log file '/app/database/dev/archive_logs/1_114_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885734598 generated at 02/03/2017 18:00:20 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_116_934902581.dbf
ORA-00280: change 461885734598 for thread 1 is in sequence #116
ORA-00278: log file '/app/database/dev/archive_logs/1_115_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885734606 generated at 02/03/2017 18:00:23 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_117_934902581.dbf
ORA-00280: change 461885734606 for thread 1 is in sequence #117
ORA-00278: log file '/app/database/dev/archive_logs/1_116_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885734614 generated at 02/03/2017 18:00:23 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_118_934902581.dbf
ORA-00280: change 461885734614 for thread 1 is in sequence #118
ORA-00278: log file '/app/database/dev/archive_logs/1_117_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885767294 generated at 02/03/2017 20:18:45 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_119_934902581.dbf
ORA-00280: change 461885767294 for thread 1 is in sequence #119
ORA-00278: log file '/app/database/dev/archive_logs/1_118_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885767302 generated at 02/03/2017 20:18:45 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_120_934902581.dbf
ORA-00280: change 461885767302 for thread 1 is in sequence #120
ORA-00278: log file '/app/database/dev/archive_logs/1_119_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885767310 generated at 02/03/2017 20:18:47 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_121_934902581.dbf
ORA-00280: change 461885767310 for thread 1 is in sequence #121
ORA-00278: log file '/app/database/dev/archive_logs/1_120_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885767325 generated at 02/03/2017 20:18:48 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_122_934902581.dbf
ORA-00280: change 461885767325 for thread 1 is in sequence #122
ORA-00278: log file '/app/database/dev/archive_logs/1_121_934902581.dbf'
no longer needed for this recovery


ORA-00279: change 461885767339 generated at 02/03/2017 20:18:50 needed for
thread 1
ORA-00289: suggestion :
/app/database/dev/archive_logs/1_123_934902581.dbf
ORA-00280: change 461885767339 for thread 1 is in sequence #123
ORA-00278: log file '/app/database/dev/archive_logs/1_122_934902581.dbf'
no longer needed for this recovery


ORA-00308: cannot open archived log
'/app/database/dev/archive_logs/1_123_934902581.dbf'
ORA-27037: unable to obtain file status
SVR4 Error: 2: No such file or directory
Additional information: 3




SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '/app/database/dev/data01/system01.dbf'

 

You still need archive log file with sequence 123, as we don't have it. We are going with incomplete recovery by using, until SCN. This SCN we can get from the last archive backup we have.

 
RMAN> list backuppiece '/app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hprrm59b_1_1_196153.rman';

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
73      73      1   1   AVAILABLE   DISK        /app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hprrm59b_1_1_196153.rman

RMAN> list backupset 73;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
73      2.50K      DISK        00:00:00     03-FEB-17
        BP Key: 73   Status: AVAILABLE  Compressed: YES  Tag: TAG20170203T201850
        Piece Name: /app/database/dev/RMAN_BKUP/fullbackup_arch_PROD_hprrm59b_1_1_196153.rman

  List of Archived Logs in backup set 73
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    121     461885767310 03-FEB-17 461885767325 03-FEB-17
  1    122     461885767325 03-FEB-17 461885767339 03-FEB-17


RMAN> recover database until scn=461885767339;


SQL> alter database open resetlogs;

Database altered.



SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
DEV      READ WRITE

SQL>

Wednesday, December 28, 2016

RMAN Technical Reference

RMAN backup, delete, reporting, charting, compression, encryption, authentication, such as crosschek control that I created a technical reference for quick access. I want to share with you. I will be updating this document periodically. I tried to classify the commands in RMAN to recover under the general headings. Hope to be useful.
Backup Reporting Operations
Backup need report:
RMAN>report need backup;
Obsolete backup report:
RMAN>report obsolete;
Back-up Operations
Backing Up whole database:
RMAN>backup database;
or
RMAN> backup incremental level 0 database;
Backing Up whole database with archive log files:
RMAN>backup database plus archivelog;
Backing Up Controlfile :
RMAN>backup as copy current controlfıle;
Backing Up whole database with archive log files and deleting arhived log files:
RMAN>backup database plus archivelog delete input;
Backing Up a Tablespace:
RMAN>backup as backupset
format '/backup/df_%d_%s.bck'
tablespace users;
Backing Up a datafile:
RMAN>backup datafile 5;
Backing Up changed blocks (Differential Incremental Backup):
RMAN> backup incremental level 1 database;
Backing Up all blocks after last full backup (Cumulative Incremental Backup):
RMAN>backup incremental level 1 cumulative database;
Image Copy Backup:
RMAN>backup as copy database;
Backup Deletion Operations
Deleting a backup by sequence number:
RMAN>delete backuppiece 101;
Deleting a backup by file name:
RMAN>DELETE CONTROLFILECOPY '/tmp/control01.ctl';
Deleting arhive log files:
RMAN>DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 300;
RMAN>DELETE NOPROMPT ARCHIVELOG ALL;
Note:NOPROMPT, During the backup deletion , it will not ask the  Yes / No  question  confirmation
Deleting a backup by tag name:
RMAN>DELETE BACKUP TAG='before_upgrade';
Deleting all backups:
RMAN>DELETE BACKUP;
Deleting a backup on the disk which backed up to tape:
RMAN>DELETE ARCHIVELOG ALL BACKED UP 3 TIMES TO sbt;
Deleting Image copy backup:
RMAN>DELETE COPY;
Deleting Obsolete Backuıp
RMAN marks backups as obsolete are not needed for the recovery process. (if you set redundancy or recovery window )
Deleting obsolete backups:
RMAN>delete obsolete;
Deleting obsolete backups older than 3 days:
RMAN> delete obsolete recovery window of 3 days;
Deleting expired backup
RMAN>delete expired backup;
Crosscheck Control
Crosscheck command checks the backup in the RMAN repository whether it exists physically on the disk or tape . If the file not exists physically on the disk or tape (can be deleted through the operating system)  it marks the backup as  “EXPIRED” in the RMAN Repository. Then, you can delete from RMAN Repository with “DELETE EXPIRED” command.
Checking Archive log files with crosscheck:
RMAN>crosscheck archivelog all;
Checking whole backup with crosscheck:
RMAN>crosscheck backup;
Checking image copy backup with crosscheck:
RMAN>crosscheck copy;
Checking tagged backup with crosscheck:
RMAN>crosscheck backuppiece tag = 'nightly_backup';
Showing Backup List
RMAN>list backupset of database;
RMAN>list backup;
Showing Backup Preview (In which objects are listed in):
RMAN> restore database preview;

RMAN> restore tablespace users preview;
Configuration Operations
See the configuration settings:
RMAN>show all;
Return to the default configuration: At the end of statement iswritten  “clear” expression.
RMAN>configure backup optimization clear;
To see a configuration that has been set: At the begining of statement is written  “set” expression
RMAN>show controlfile autobackup format;
To configure a setting: At the begining of statement is written  “configure” expression
RMAN>configure device type disk backup type to copy;

RMAN>configure retention policy to recovery window of 7 days;

RMAN>configure retention policy to redundancy 3;
Verification Operations (validate) 
Verification whole backup:
RMAN>backup validate;
Verification archive log files backup:
RMAN>backup validate database archivelog all;
Verification whole database restore:
RMAN>restore database validate;
Verification control file restore:
RMAN>restore controlfile validate;
Verification spfile restore:
RMAN>restore spfile validate;
Verification a tablespace restore:
RMAN>restore tablespace users validate;
Backup Compression Operations (After 11g)
Compression a backupset:
RMAN>backup as compressed backupset database;
Backup Encryption  Operations
Setting the Encryption :
RMAN> Set  encryption identified by passwprd;
Setting the Decryption:
RMAN> Set  decryption identified by passwprd;
Enable & Disable Block change tracking
BCT to be active only changed blocks to keep track of:
SQL>alter database enable block change tracking using file '/rman_bkups/change.log';
Disabling Block change tracking:
SQL>alter database disable block change tracking;
To debug and trace RMAN backup
$rman target=/ debug=all trace=rman.trc
Create the backup log file
$export NLS_DATE_FORMAT=’dd.mm.yyyy hh24:mi:ss’;

$rman target=/ log=rman.log
Recovery area size information
select name
,        floor(space_limit / 1024 / 1024) "Size MB"
,        ceil(space_used  / 1024 / 1024) "Used MB"
from   v$recovery_file_dest
order by name
/
RMAN Catalog DB operations
  1. Create a user on catalog db.
  CREATE USER rman IDENTIFIED BY rman
  TEMPORARY TABLESPACE temp
  DEFAULT TABLESPACE users
  QUOTA UNLIMITED ON users;
  1. Grant Recovery Catalog owner to that user
GRANT RECOVERY_CATALOG_OWNER TO rman;
  1. Connect to catalog db and create catalog
rman CATALOG rman/rman@catalog
RMAN> create catalog;
  1. Register to target database which will be backed up.
rman TARGET sys/oracle@test10g CATALOG rman/rman@catolog RMAN> register database;
Opening channels in RMAN and  distribute objects to channels
Example:
RUN
{
  ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS="ENV=(BACKUP_SERVER=tape_server1)";
  ALLOCATE CHANNEL c2 DEVICE TYPE sbt PARMS="ENV=(BACKUP_SERVER=tape_server2)";
  ALLOCATE CHANNEL c3 DEVICE TYPE sbt PARMS="ENV=(BACKUP_SERVER=tape_server3)";
  BACKUP
   (DATAFILE 1,2,3
    CHANNEL c1)
   (DATAFILECOPY '/tmp/system01.dbf', '/tmp/tools01.dbf'
     CHANNEL c2)
   (ARCHIVELOG FROM SEQUENCE 100 UNTIL SEQUENCE 102 THREAD 1
     CHANNEL c3);
}
 
 
 
source:
https://taliphakanozturken.wordpress.com/tag/delete-obsolete-backup/ 

Tuesday, September 27, 2016

Creating and Dropping UNDO Tablespace


SHOW PARAMETER UNDO

CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE '&undofile/undotbs201.dbf' SIZE 50M AUTOEXTEND ON NEXT 5M;

ALTER SYSTEM SET UNDO_TABLESPACE=UNDOTBS2 SCOPE=BOTH;

DROP TABLESPACE APPS_UNDOTS1 INCLUDING CONTENTS AND DATAFILES;








CREATE UNDO TABLESPACE APPS_UNDOTS1 DATAFILE '&undofile/undo01.dbf' SIZE 50M AUTOEXTEND ON NEXT 5M;

ALTER SYSTEM SET UNDO_TABLESPACE=APPS_UNDOTS1 SCOPE=BOTH;

DROP TABLESPACE UNDOTBS2 INCLUDING CONTENTS AND DATAFILES;

SHOW PARAMETER UNDO

Friday, July 29, 2016

Oracle11g Data Pump EXPDP Query Parameter


SOURCE:

expdp
system/*****
DIRECTORY=DATA_PUMP_DIR
DUMPFILE=emp_jan16.dmp
LOGFILE=emp_jan16.log
TABLES=scott.emp
QUERY=emp:\"WHERE conversion_date between \'01-JAN-2016\' and \'31-JAN-2016\'\"

OR

expdp parfile=emp_jan16.par

DIRECTORY=DATA_PUMP_DIR
DUMPFILE=emp_jan16.dmp
LOGFILE=emp_jan16.log
TABLES=scott.emp
QUERY=emp:"WHERE conversion_date between '01-JUN-2016' and '28-JUN-2016'"



DESTINATION:

impdp
system/*****
DIRECTORY=DATA_PUMP_DIR
DUMPFILE=emp_jan16.dmp
LOGFILE=emp_jan16_import.log
REMAP_SCHEMA=scott:scott
TABLE_EXISTS_ACTION=APPEND

Tuesday, October 20, 2015

RMAN: Cold Backup Script

#!/bin/sh
# Set Oracle Environment for DB
#. ~/.bashrc
. ~/.bash_profile

echo
echo "`date` – Started `basename $0`"
echo

export NLS_DATE_FORMAT='DD-MON-YY HH24:MI:SS'
rman target / << EOF
spool log to rman_coldbackup.log;
set echo on
run
{
shutdown immediate;
startup mount;
allocate channel ch1 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch2 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch3 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch4 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch5 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';
allocate channel ch6 type disk format '/export/dbclone/DEV_RMAN_COLDBKP/full_backup_%d_%s_%p';

BACKUP CURRENT CONTROLFILE format '/export/dbclone/DEV_RMAN_COLDBKP/ctrl_file_%d_%s_%p';
BACKUP AS COMPRESSED BACKUPSET DATABASE;

release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
release channel ch6;

alter database open;
}
EOF
if [ $? -eq 0 ]
then
echo "====================="
echo "RMAN Backup Completed"
echo "====================="
else
echo "=================="
echo "RMAN Backup Failed"
echo "=================="
exit 1
fi

echo
echo "`date` - Finished `basename $0`"
echo

Monday, September 29, 2014

ORA-00000: normal, successful completion

This error may occur in many circumstances you need to check environment variables:
$ORACLE_HOME
$ORACLE_BASE
$ORACLE_SID
also check /etc/hosts file it must contains correct hostname and ip.
example:

[oracle@oel6 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 27 11:55:17 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.
SQL> startup;
ORA-00000: normal, successful completion
after that i checked environment variables:
[oracle@oel6 ~]$ echo $ORACLE_BASE
/u0/app/oracle
[oracle@oel6 ~]$ echo $ORACLE_HOME
/u0/app/oracle/product/11.2.0/dbhome_1
[oracle@oel6 ~]$ echo $ORACLE_SID
orcl
it’s correct, then checked /etc/host file
cat /etc/hosts
#10.10.1.176 oel6
bingo! someone maybe system administrator or other dba commented this machine hostname and ip, hence we can’t start database, uncomment it and everything goes correct.
vi /etc/hosts
10.10.1.176 oel6

sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Jan 27 12:03:10 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2232960 bytes
Variable Size             645926272 bytes
Database Buffers          180355072 bytes
Redo Buffers                6590464 bytes
Database mounted.
Database opened.
 

Thursday, September 4, 2014

All about relinking in Oracle

1)  What is relinking ?
The predefined functions for any language are defined inside the library files for that language  and it is required to Compile the code to create a binary format file (object file).The Object files are then linked together with OS libraries to create one executable file. Successful linking requires all the function definition should be found , Linking generates an executable from it's component. The terms linking and relinking mean the same in this context and used interchangeably. In both cases an executable is being built from pre-built components.

The types of files involved in relinking are:

* .c   (source code file)
* .o   (object file)
* .a   (archived file)
* .so or .sl on HP/UX (PA-RISC)  (library files)







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

2)  What is relinking of Oracle Home Binaries ?
The Oracle software is shipped in form of object files (.o files),  archive files (.a files) and then grouped in a compressed jar format. These object files are then get "relinked" at the operating system level during installation to create usable executables.  This guarantees a reliable integration with functions provided by the OS system libraries. Generally, during relinking the current executables are renamed and saved, while the new executables are being generated. Once the new executables are in place and you have successfully tested that the new executables are working, you can delete the old executables in the directory ORACLE_HOME/bin. Each old executable has an 'O' appended to it's file name, for example, 'exp' is renamed to 'expO'.

The advantage of providing the object file is that it reduces the patch/package size , instead of providing the whole libraries  or program , only objects files are shipped which then linked with OS libraries to create usable executables.



 The following are the directories where various object files and archive files will reside in Oracle Home.

- /lib

- /usr/lib

- $ORACLE_HOME/lib

- $ORACLE_HOME/rdbms/lib

- $ORACLE_HOME/<product>/lib

There is file named “ sysliblist “ which lives in $ORACLE_HOME/rdbms/lib or $ORACLE_HOME/lib directory. It contains a list of other libraries, which need to be included.






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

3)  Why Oracle Home Relinking is required ?
Oracle Home relinking  is required to link Oracle provided object files to the OS system library. Relinking  guarantees a reliable integration with functions provided by the OS system libraries.



Relinking occurs automatically under these circumstances:

An Oracle Database has  been  installed with Oracle Universal Installer ( OUI )
An Oracle Database Patchset  has been applied via Oracle Universal Installer ( OUI )
An Oracle Database Patch has been applied  using  “ opatch tool “
Relinking can also be performed manually.






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

4)  When Manual relinking is required?
Manual relinking is required in below situations.

A)  After OS upgrade, Generally OS Vendors guarantee operating system binary compatibility, therefore, no  reinstall or relink of the Oracle software is required when upgrading these operating systems unless  specifically stated otherwise.

"However Oracle recommends performing manual relinking of Oracle Home binaries after OS upgrade".

B)   After Operating system has been patched.( Recommended ).

C)   Relinking phase during installation of Oracle Home has errors/warnings.

D)  Application of a RDBMS patch failed in relinking phase.

E)   Applications gives error for missing lib files in RDBMS home.

F)   Troubleshooting RDBMS home binaries issue.

G)  After manually modifying RDBMS home binary permissions.

H)  Verifying Integrity of Oracle Home Binaries.

I)  Resetting Oracle Home binaries permission.




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



5)  Is relinking required after an OS upgrade , Downgrade , Patching or removal of the patch ?
Yes, Oracle recommends to perform manual relinking of Oracle Home Binaries after OS Upgrade , Patching , Downgrade or removal of the Patch or any change which impact OS library behavior . Successful relinking shows Oracle Executable are properly linked with OS binaries.


For more info check Metalink:

root.sh - Purpose of oraenv, coraenv & dbhome

The oraenv and coraenv utilities both aid in setting the Oracle environment on UNIX systems (other utilities exist on Windows platform that enable the Oracle Home to be set.) The coraenv utility is appropriate for the UNIX C Shell; oraenv should be used with either the Bourne or Korn shells.

Database operations require the ORACLE_HOME to be set before the user may access the database. If ORACLE_HOME is not set, commands such as sqlplus, exp, or any other utility for that matter, will not be found.

Both utilities are shell scripts that do the same thing in the different UNIX shells. They will prompt for a SID of the database unless ORAENV_ASK is set to N. The utility will also append the ORACLE_HOME value to the path, marking the location of the utility.

The oraenv command will prompt for the SID of the database that you wish $ORACLE_HOME to access.

$ . oraenv

ORACLE_SID = [] ? ASG920

The dbhome utility can now be used to verify that $ORACLE_HOME is correct.

$ dbhome

/usr/oracle/9.2.0

The “dot space” part of the command is required to make the environment change with the parent shell, as opposed to entering a command without it which would only affect the subshell running that process.

These commands can be used to avoid specifying the network service name when issuing commands. For instance, without using oraenv, a sqlplus command would look like:

$ sqlplus system/manager@nameofservice as sysdba

whereas after oraenv has been executed, the following command would work:

$ sqlplus system/manager as sysdba



Source: http://blog.abigold.fr/joomla/index.php?option=com_content&view=article&id=200:oraenvcoraenvdbhome&catid=41:command-batch-utility-utilitaire&Itemid=66