How To Create A New bash_profile And Connect New Database To It In Oracle [closed]
-
17-02-2021 - |
Question
OS -> Linux
DB -> Oracle 11gR2
Normally my .bash_profile file looks like this:
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_HOSTNAME=abcde.localdomain; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
But I need to do that:
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/newdb
After that I have to create a new database in newdb.
I'm a newbie oracler and I couldn't find any clear solution. Should I create a directory as newdb and set a new .bash_profile file? If it's a clear solution, how can I do it and after that will my dbca and netca operations work fine? Or something else like this?
Thank you.
Solution
First, remove all that junk from .bash_profile
. Use oraenv
. Example:
$ grep u01 /etc/oratab
MIN112:/u01/app/oracle/product/11.2.0/dbhome_1:N
MIN121:/u01/app/oracle/product/12.1.0/dbhome_1:N
$ . oraenv
ORACLE_SID = [oracle] ? MIN112
The Oracle base has been set to /u01/app/oracle
$ env | grep ORA | sort
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_SID=MIN112
$ . oraenv
ORACLE_SID = [MIN112] ? MIN121
The Oracle base remains unchanged with value /u01/app/oracle
$ env | grep ORA | sort
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
ORACLE_SID=MIN121
Second, forget /u01/app/oracle/product/newdb
.
Just run /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbca
and create your other database and provide the necesarry path for datafiles. You do not need another ORACLE_HOME
for another database.
When you have multiple databases, just put them in /etc/oratab
(dbca will do this automatically in 11.2), and use oraenv
or just set ORACLE_SID
in case of the same ORACLE_HOME
for switching between them.