How to install Oracle Database 18c XE on Linux

The new version of the free Oracle Database edition, Oracle Database 18c Express Edition, just got released for Linux 64-bit. Getting started is really simple on Oracle Linux, basically a three step process of downloading the RPM file, installing it and then configuring the database. On other Red Hat  compatible Linux distributions you will also have to download the Oracle Database Preinstall RPM alongside the XE RPM file. Here is a quick guide on how to setup Oracle Database 18c XE.

tl;dr

Oracle Linux

  1. Download the RPM file from Oracle Technology Network
  2. Run “yum -y localinstall oracle-database*18c*
  3. Run “/etc/init.d/oracle-xe-18c configure

Other Red Hat compatible Linux distribution

  1. Download the RPM file from Oracle Technology Network
  2. Download the Oracle Database Preinstall RPM via “curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm
  3. Run “yum -y localinstall oracle-database*18c*
  4. Run “/etc/init.d/oracle-xe-18c configure

Downloading the RPM file

The download is straight forward as usual. Just head over to https://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html, accept the license agreement after reading it, and download the RPM file.

Downloading the Oracle Database Preinstall RPM file

If you run on Oracle Linux, you can skip this step! The Oracle Database Preinstall RPM file will be pulled automatically by the yum command.

Download the Oracle Database Preinstall RPM by executing:

curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

If you happen to be behind a firewall and need to specify a proxy, you can do so by running “export https_proxy=:; export http_proxy=:” beforehand, for example:

export https_proxy=proxy.example.com:80
export http_proxy=proxy.example.com.80
curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

Installing the RPM file

In order to install the RPM file(s) you will have to have root privileges. This means that you either have to have access to the root user or have sudo permissions. To install the Oracle Database 18c XE binaries, execute:

yum –y localinstall oracle-database*18c*

Note that the rpm file has to be in the working directory where you execute yum. Once yum is running, you will see a similar output to this:

[root@localhost gerald]# yum -y localinstall oracle-database-xe-18c-1.0-1.x86_64.rpm
Loaded plugins: langpacks, ulninfo
Examining oracle-database-xe-18c-1.0-1.x86_64.rpm: oracle-database-xe-18c-1.0-1.x86_64
Marking oracle-database-xe-18c-1.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-database-xe-18c.x86_64 0:1.0-1 will be installed
--> Processing Dependency: oracle-database-preinstall-18c for package: oracle-database-xe-18c-1.0-1.x86_64
ol7_UEKR4 | 1.2 kB 00:00:00
ol7_latest | 1.4 kB 00:00:00
(1/4): ol7_UEKR4/x86_64/updateinfo | 80 kB 00:00:00
(2/4): ol7_latest/x86_64/updateinfo | 568 kB 00:00:00
(3/4): ol7_UEKR4/x86_64/primary | 2.5 MB 00:00:00
(4/4): ol7_latest/x86_64/primary | 7.8 MB 00:00:01
ol7_UEKR4 110/110
ol7_latest 8768/8768
--> Running transaction check
---> Package oracle-database-preinstall-18c.x86_64 0:1.0-1.el7 will be installed
--> Processing Dependency: compat-libcap1 for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Processing Dependency: ksh for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Processing Dependency: libaio-devel for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Processing Dependency: glibc-devel for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Processing Dependency: compat-libstdc++-33 for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Processing Dependency: libstdc++-devel for package: oracle-database-preinstall-18c-1.0-1.el7.x86_64
--> Running transaction check
---> Package compat-libcap1.x86_64 0:1.10-7.el7 will be installed
---> Package compat-libstdc++-33.x86_64 0:3.2.3-72.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-222.0.7.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-222.0.7.el7 for package: glibc-devel-2.17-222.0.7.el7.x86_64
--> Processing Dependency: glibc = 2.17-222.0.7.el7 for package: glibc-devel-2.17-222.0.7.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-222.0.7.el7.x86_64
---> Package ksh.x86_64 0:20120801-137.0.1.el7 will be installed
---> Package libaio-devel.x86_64 0:0.3.109-13.el7 will be installed
---> Package libstdc++-devel.x86_64 0:4.8.5-28.0.1.el7_5.1 will be installed
--> Running transaction check
---> Package glibc.x86_64 0:2.17-222.el7 will be updated
--> Processing Dependency: glibc = 2.17-222.el7 for package: glibc-common-2.17-222.el7.x86_64
---> Package glibc.x86_64 0:2.17-222.0.7.el7 will be an update
---> Package glibc-headers.x86_64 0:2.17-222.0.7.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-222.0.7.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-222.0.7.el7.x86_64
--> Running transaction check
---> Package glibc-common.x86_64 0:2.17-222.el7 will be updated
---> Package glibc-common.x86_64 0:2.17-222.0.7.el7 will be an update
---> Package kernel-headers.x86_64 0:3.10.0-862.14.4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing:
oracle-database-xe-18c x86_64 1.0-1 /oracle-database-xe-18c-1.0-1.x86_64 5.2 G
Installing for dependencies:
compat-libcap1 x86_64 1.10-7.el7 ol7_latest 17 k
compat-libstdc++-33 x86_64 3.2.3-72.el7 ol7_latest 190 k
glibc-devel x86_64 2.17-222.0.7.el7 ol7_latest 1.1 M
glibc-headers x86_64 2.17-222.0.7.el7 ol7_latest 679 k
kernel-headers x86_64 3.10.0-862.14.4.el7 ol7_latest 7.1 M
ksh x86_64 20120801-137.0.1.el7 ol7_latest 881 k
libaio-devel x86_64 0.3.109-13.el7 ol7_latest 12 k
libstdc++-devel x86_64 4.8.5-28.0.1.el7_5.1 ol7_latest 1.5 M
oracle-database-preinstall-18c x86_64 1.0-1.el7 ol7_latest 18 k
Updating for dependencies:
glibc x86_64 2.17-222.0.7.el7 ol7_latest 3.6 M
glibc-common x86_64 2.17-222.0.7.el7 ol7_latest 11 M

Transaction Summary
=====================================================================================================================================
Install 1 Package (+9 Dependent packages)
Upgrade ( 2 Dependent packages)

Total size: 5.2 G
Total download size: 27 M
Downloading packages:
No Presto metadata available for ol7_latest
(1/11): compat-libcap1-1.10-7.el7.x86_64.rpm | 17 kB 00:00:00
(2/11): compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm | 190 kB 00:00:00
(3/11): glibc-2.17-222.0.7.el7.x86_64.rpm | 3.6 MB 00:00:01
(4/11): glibc-devel-2.17-222.0.7.el7.x86_64.rpm | 1.1 MB 00:00:00
(5/11): glibc-headers-2.17-222.0.7.el7.x86_64.rpm | 679 kB 00:00:00
(6/11): glibc-common-2.17-222.0.7.el7.x86_64.rpm | 11 MB 00:00:03
(7/11): ksh-20120801-137.0.1.el7.x86_64.rpm | 881 kB 00:00:00
(8/11): kernel-headers-3.10.0-862.14.4.el7.x86_64.rpm | 7.1 MB 00:00:01
(9/11): libaio-devel-0.3.109-13.el7.x86_64.rpm | 12 kB 00:00:00
(10/11): oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm | 18 kB 00:00:00
(11/11): libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64.rpm | 1.5 MB 00:00:00
-------------------------------------------------------------------------------------------------------------------------------------
Total 6.1 MB/s | 27 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : glibc-common-2.17-222.0.7.el7.x86_64 1/14
Updating : glibc-2.17-222.0.7.el7.x86_64 2/14
Installing : compat-libcap1-1.10-7.el7.x86_64 3/14
Installing : compat-libstdc++-33-3.2.3-72.el7.x86_64 4/14
Installing : ksh-20120801-137.0.1.el7.x86_64 5/14
Installing : libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64 6/14
Installing : libaio-devel-0.3.109-13.el7.x86_64 7/14
Installing : kernel-headers-3.10.0-862.14.4.el7.x86_64 8/14
Installing : glibc-headers-2.17-222.0.7.el7.x86_64 9/14
Installing : glibc-devel-2.17-222.0.7.el7.x86_64 10/14
Installing : oracle-database-preinstall-18c-1.0-1.el7.x86_64 11/14
Installing : oracle-database-xe-18c-1.0-1.x86_64 12/14
[INFO] Executing post installation scripts...
[INFO] Oracle home installed successfully and ready to be configured.
To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-18c.conf' and then execute '/etc/init.d/oracle-xe-18c configure' as root.
Cleanup : glibc-common-2.17-222.el7.x86_64 13/14
Cleanup : glibc-2.17-222.el7.x86_64 14/14
Verifying : glibc-2.17-222.0.7.el7.x86_64 1/14
Verifying : kernel-headers-3.10.0-862.14.4.el7.x86_64 2/14
Verifying : glibc-common-2.17-222.0.7.el7.x86_64 3/14
Verifying : oracle-database-preinstall-18c-1.0-1.el7.x86_64 4/14
Verifying : glibc-headers-2.17-222.0.7.el7.x86_64 5/14
Verifying : compat-libcap1-1.10-7.el7.x86_64 6/14
Verifying : compat-libstdc++-33-3.2.3-72.el7.x86_64 7/14
Verifying : glibc-devel-2.17-222.0.7.el7.x86_64 8/14
Verifying : libaio-devel-0.3.109-13.el7.x86_64 9/14
Verifying : libstdc++-devel-4.8.5-28.0.1.el7_5.1.x86_64 10/14
Verifying : oracle-database-xe-18c-1.0-1.x86_64 11/14
Verifying : ksh-20120801-137.0.1.el7.x86_64 12/14
Verifying : glibc-common-2.17-222.el7.x86_64 13/14
Verifying : glibc-2.17-222.el7.x86_64 14/14

Installed:
oracle-database-xe-18c.x86_64 0:1.0-1

Dependency Installed:
compat-libcap1.x86_64 0:1.10-7.el7 compat-libstdc++-33.x86_64 0:3.2.3-72.el7
glibc-devel.x86_64 0:2.17-222.0.7.el7 glibc-headers.x86_64 0:2.17-222.0.7.el7
kernel-headers.x86_64 0:3.10.0-862.14.4.el7 ksh.x86_64 0:20120801-137.0.1.el7
libaio-devel.x86_64 0:0.3.109-13.el7 libstdc++-devel.x86_64 0:4.8.5-28.0.1.el7_5.1
oracle-database-preinstall-18c.x86_64 0:1.0-1.el7

Dependency Updated:
glibc.x86_64 0:2.17-222.0.7.el7 glibc-common.x86_64 0:2.17-222.0.7.el7

Complete!

Once yum executed successfully, the Oracle Database 18c Express Edition binaries are installed. Next and last step is to configure the database itself.

Configuring the database

To configure the XE database you need to run /etc/init.d/oracle-xe-18c configure, once again, as either root or with root privileges.

[root@localhost gerald]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts.
Oracle recommends that the password entered should be at least 8 characters in length,
contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:

Type in and confirm the password for the administrative accounts, SYS, SYSTEM and PDBADMIN, and hit Enter.

Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
Enter SYS user password:
***************
Enter SYSTEM user password:
************
Enter PDBADMIN User Password:
*************
Prepare for db operation
7% complete
Copying database files
29% complete
Creating and starting Oracle instance
30% complete
31% complete
34% complete
38% complete
41% complete
43% complete
Completing Database Creation
47% complete
50% complete
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE.log" for further details.

Connect to Oracle Database using one of the connect strings:
Pluggable database: localhost.localdomain/XEPDB1
Multitenant container database: localhost.localdomain
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
[root@localhost gerald]#

After the command has finished, the Oracle Database 18c XE is fully configured and ready to use.

Connecting to Oracle Database 18c XE

To fire up the SQL prompt for your user, you will have to make sure that $ORACLE_HOME is set and $ORACLE_HOME/bin in your $PATH. There is a utility script called oraenv, that will configure that and more for your. All you have to do is to call it for your local shell (note the . before the script name below) and pass on the $ORACLE_SID, which is XE:

[gerald@localhost ~]$ . oraenv
ORACLE_SID = [gerald] ? XE
ORACLE_BASE environment variable is not being set since this
information is not available for the current user ID gerald.
You can set ORACLE_BASE manually if it is required.
Resetting ORACLE_BASE to its previous value or ORACLE_HOME
The Oracle base has been set to /opt/oracle/product/18c/dbhomeXE

Once you have done that you can connect via the SQL prompt. The format for the connect string is: [user]/[password]@//[hostname]:[port]/[DB name] [AS [role]]

[gerald@localhost ~]$ sqlplus sys/GetStarted18c@//localhost:1521/XE as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Fri Oct 19 09:05:41 2018
Version 18.4.0.0.0

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

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> SELECT 'Hello World!' FROM dual;

'HELLOWORLD!
------------
Hello World!

SQL> exit
Disconnected from Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

More information

Author: Gerald

Developer, Oracle expert, performance enthusiast and genuine technology geek.

16 thoughts on “How to install Oracle Database 18c XE on Linux”

  1. Hi! What kind of “Red Hat compatible Linux distribution” you used? If it is CentOS what version?
    I tried the newest 7.5.1804 (Minimal-ISO) and everything is fine until the db configuration (Listener configuration failed). It seems not to be the only one with the problem – I found these (unanswered) posts: https://community.oracle.com/thread/4180595

    Any ideas?

    Like

    1. Hi Carlos,

      There is only one kind of Red Hat compatible OS, which are those that support the RedHat Package Manager (RPM) and the same libraries.

      The issue in the community post is that the underlying Java VM crashes when executing a Java program. Do you have the same issue?

      You might want to post your issue in the community forum as well.

      Thx,

      Like

      1. Yes. I have exactly the same problem. For me it’s interesting that it doesn’t work “out of the box” although I downloaded a fresh centos without modifying nothing (except updates and the oracle presinstall package). It seems to be a very specific problem with – you’re right – the underlying JAVA VM. You don’t had this issue when you install 18c XE on the “red hat compatible OS”? Can you post what distribution and kernel version you used for your test (the video)? And what JAVA (java -version) is installed? OpenJDK or Oracles Java (8 or 9)?

        And yes… I will post in the forum too. Hoped that the issue (4180595) solved earlier…

        Like

        1. Hey Carlos,

          The versions for Oracle Linux I have XE running, is:

          [gerald@localhost ~]$ cat /etc/oracle-release
          Oracle Linux Server release 7.5
          [gerald@localhost ~]$ uname -a
          Linux localhost.localdomain 4.1.12-124.19.7.el7uek.x86_64 #2 SMP Sat Sep 29 17:29:22 PDT 2018 x86_64 x86_64 x86_64 GNU/Linux

          The Java version used for netca gets shipped with the installation. When you look at $ORACLE_HOME/bin/netca you will find the following lines:

          99 # External Directory Variables set by the Installer
          100 JRE_DIR=/opt/oracle/product/18c/dbhomeXE/jdk/jre
          101 JLIB_DIR=/opt/oracle/product/18c/dbhomeXE/jlib
          102
          103
          104 # JRE Executable and Class File Variables
          105 JRE=$JRE_DIR/bin/java

          That Java version itself will be the same as for you:

          -bash-4.2$ /opt/oracle/product/18c/dbhomeXE/jdk/jre/bin/java -version
          java version “1.8.0_171”
          Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
          Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

          On the Red Hat compatible OS I also used CentOS:

          [gerald@localhost ~]$ cat /etc/centos-release
          CentOS Linux release 7.5.1804 (Core)
          [gerald@localhost ~]$ uname -a
          Linux localhost.localdomain 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

          [oracle@localhost ~]$ /opt/oracle/product/18c/dbhomeXE/jdk/jre/bin/java -version
          java version “1.8.0_171”
          Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
          Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

          Like

    2. Carlos,

      I’ve found that re-running the configuration after it fails the first time works for me, so I’m using the following command:

      # /etc/init.d/oracle-xe-18c configure 2>&1 || \
      > cat /opt/oracle/cfgtoollogs/netca/netca_configure_out.log && \
      > /etc/init.d/oracle-xe-18c configure 2>&1

      Like

  2. Hey David,
    thanks for you answer – but it didn’t work for me! I’ve tried it several times in different states of my virtual environment but always failed.

    You’ve executed all these commands as root user? Or as oracle user with root privileges (sudo)? You used the minimal ISO (no GUI) from CentOS? Did you update the system after configuring? You used VirtualBox too?

    Like

    1. Found the solution: don’t update your fresh centos installation. Then there are no problems…
      (don’t ask me why – but it works)

      Like

  3. Hey Gerald!

    Thanks for everything you are doing for the XE community!

    I have a very tricky question for you about the oraenv script. In the ‘Administering Oracle Database’ documentation (https://docs.oracle.com/en/database/oracle/oracle-database/18/unxar/administering-oracle-database.html) it is said that oraenv script should use the oratab contents in order to determine the ORACLE_SID and ORACLE_HOME environment variables. If it fails, then it asks the user to specify them.

    But I checked the script contents and never found utilizing of the oratab file, although I have it under /etc directory in my system and there’s a row containing all the needed information: XE:/opt/oracle/product/18c/dbhomeXE:N.

    At the moment, to be able to run the oraenv script in the non-interactive regime (as a part of /etc/profile.d scripts, to set up the environment by default for all new sessions), I first set the ORACLE_SID and ORAENV_ASK environment variables to the corresponding values and only then run the script, which is not quite convinient. Indeed, the sctipt didn’t have to ask me to provide the values, it could use my oratab contents instead.

    The question is – is there a bug or was all this done on any purpose that the script don’t quite reflect the facts written in the official docs?

    Like

    1. Hi Denis,

      Thank you very much!

      I will have to check and see what it does. It should retrieve the values from /etc/oratab, otherwise how would it get to the ORACLE_HOME.
      What actually happens when you run . oraenv and pass on ORACLE_SID=XE? Does it set the ORACLE_HOME and PATH correctly?

      Btw, that is the only thing that oraenv does. You can just happily set ORACLE_HOME, ORACLE_SID, and PATH yourself and don’t even need to invoke oraenv

      Thx,

      Like

      1. Hi Gerald!

        Well, I had a look at the script contents before worked out my solution.

        So, basically yes, it does set the ORACLE_HOME and PATH env variables when you provide it with the ORACLE_SID env variable value and set the ORAENV_ASK variable value to NO. Otherwise, despite the fact that ORACLE_SID is already set, it asks for its value from keyboard, however the default value is changed from the OS user name (‘root’ in my case) to ‘XE’.

        I haven’t found any usage of /etc/oratab inside the script, which I have with my 18c XE distribution. Although, I didn’t look into the ‘dbhome.sh’ script, which is executed inside ‘oraenv.sh’.

        Like

        1. Hey Denis,

          It is indeed in dbhome that the /etc/oratab is read:

          [gerald@localhost ~]$ export ORACLE_TRACE=T
          [gerald@localhost ~]$ . oraenv
          ++ N=
          ++ C=
          ++ grep --color=auto c
          ++ echo '\c'
          ++ N=-n
          ++ '[' /opt/oracle/product/18c/dbhomeXE = 0 ']'
          ++ OLDHOME=/opt/oracle/product/18c/dbhomeXE
          ++ case ${ORAENV_ASK:-""} in
          ++ case "$ORACLE_SID" in
          ++ ORASID=XE
          ++ echo -n 'ORACLE_SID = [XE] ? '
          ORACLE_SID = [XE] ? ++ read NEWSID
          XE
          ++ case "$NEWSID" in
          ++ ORACLE_SID=XE
          ++ export ORACLE_SID
          +++ dbhome XE
          ++++ trap '' 1
          ++++ RET=0
          ++++ ORAHOME=
          ++++ ORASID=XE
          ++++ ORASID=XE
          ++++ ORATAB=/etc/oratab
          ++++ PASSWD=/etc/passwd
          ++++ PASSWD_MAP=passwd.byname
          ++++ case "$ORASID" in
          ++++ test -f /etc/oratab
          ++++ case "$ORASID" in
          +++++ awk -F: '{if ($1 == "XE") {print $2; exit}}' /etc/oratab
          ++++ ORAHOME=/opt/oracle/product/18c/dbhomeXE
          ++++ case "$ORAHOME" in
          ++++ echo /opt/oracle/product/18c/dbhomeXE
          ++++ exit 0
          ++ ORAHOME=/opt/oracle/product/18c/dbhomeXE
          ++ case $? in
          ++ ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
          ++ export ORACLE_HOME
          ++ case ${LD_LIBRARY_PATH:-""} in
          +++ echo /opt/oracle/product/18c/dbhomeXE/lib
          +++ sed 's;/opt/oracle/product/18c/dbhomeXE/lib;/opt/oracle/product/18c/dbhomeXE/lib;g'
          ++ LD_LIBRARY_PATH=/opt/oracle/product/18c/dbhomeXE/lib
          ++ export LD_LIBRARY_PATH
          ++ case "$OLDHOME" in
          ++ case "$PATH" in
          +++ echo /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/gerald/.local/bin:/home/gerald/bin:/opt/oracle/product/18c/dbhomeXE/bin
          +++ sed 's;/opt/oracle/product/18c/dbhomeXE/bin;/opt/oracle/product/18c/dbhomeXE/bin;g'
          ++ PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/gerald/.local/bin:/home/gerald/bin:/opt/oracle/product/18c/dbhomeXE/bin
          ++ export PATH
          +++ LANG=C
          +++ ulimit
          ++ ULIMIT=unlimited
          ++ '[' 0 = 0 -a unlimited '!=' unlimited ']'
          ++ ORABASE_EXEC=/opt/oracle/product/18c/dbhomeXE/bin/orabase
          ++ '[' /opt/oracle/product/18c/dbhomeXE '!=' x ']'
          ++ OLD_ORACLE_BASE=/opt/oracle/product/18c/dbhomeXE
          ++ unset ORACLE_BASE
          ++ export ORACLE_BASE
          ++ '[' -r /opt/oracle/product/18c/dbhomeXE/install/orabasetab ']'
          ++ '[' '' '!=' true ']'
          ++ echo 'ORACLE_BASE environment variable is not being set since this'
          ORACLE_BASE environment variable is not being set since this
          ++ echo 'information is not available for the current user ID gerald.'
          information is not available for the current user ID gerald.
          ++ echo 'You can set ORACLE_BASE manually if it is required.'
          You can set ORACLE_BASE manually if it is required.
          ++ '[' x = x ']'
          ++ '[' '' '!=' true ']'
          ++ echo 'Resetting ORACLE_BASE to its previous value or ORACLE_HOME'
          Resetting ORACLE_BASE to its previous value or ORACLE_HOME
          ++ '[' /opt/oracle/product/18c/dbhomeXE '!=' '' ']'
          ++ ORACLE_BASE=/opt/oracle/product/18c/dbhomeXE
          ++ '[' '' '!=' true ']'
          ++ echo 'The Oracle base remains unchanged with value /opt/oracle/product/18c/dbhomeXE'
          The Oracle base remains unchanged with value /opt/oracle/product/18c/dbhomeXE
          ++ export ORACLE_BASE
          ++ printf '\033]0;%s@%s:%s\007' gerald localhost '~'
          

          See:

          ORACLE_SID = [XE] ? ++ read NEWSID
          XE
          ++ case "$NEWSID" in
          ++ ORACLE_SID=XE
          ++ export ORACLE_SID
          +++ dbhome XE
          ++++ trap '' 1
          ++++ RET=0
          ++++ ORAHOME=
          ++++ ORASID=XE
          ++++ ORASID=XE
          ++++ ORATAB=/etc/oratab
          ++++ PASSWD=/etc/passwd
          ++++ PASSWD_MAP=passwd.byname
          ++++ case "$ORASID" in
          ++++ test -f /etc/oratab
          ++++ case "$ORASID" in
          +++++ awk -F: '{if ($1 == "XE") {print $2; exit}}' /etc/oratab
          ++++ ORAHOME=/opt/oracle/product/18c/dbhomeXE
          

          Like

          1. Right. Now I understnad that by reading oratab file dbhome script determines which to use if there are several of them, and it does it by the SID given to the script.

            Ok, but the issue is in the different place. The thing is that oraenv script does not have any defaults in 18c and does not take SID as an argument (as dbhome does).

            This means it always expect SID already set in the environment along with ORAENV_ASK set to NO. Otherwise it demands it from keyboard, which is very inconvinient if a user like me wants to set the environment by default. Ok, there is a workaround (which I demonstrated), but maybe it would be nicer if the script read ORACLE_SID value as an argument? Like . oraenv XE – and in this case it would respect the given value and would not ask the user to specify one.

            Just a kind suggestion.

            Like

            1. Hi Denis,

              That is the standard way of oraenv across all editions and since many versions. If you want it non-interactive you will have to set ORAENV_ASK=NOfirst.
              As you said, the reason why /etc/oratab is scanned is for different ORACLE_SIDs, which is not the case for XE but then again, it’s the very same script as with the other editions and versions.

              Is setting these two environment variables really that much of a big deal?
              Mostly people just have

              export ORACLE_HOME=
              export PATH=$ORACLE_HOME:$PATH
              export ORALCE_SID=
              

              in their bash_profile and continue like that. Of course you can also always use dbhome directly if you want as well.

              Thx,

              Like

              1. Hi Gerald,

                If this is an official way recommended by Oracle, then I am quite ok with it. And I suppose I’ll stay with it for future. In fact, I wasn’t complaining, I just tried to make a suggestion, because, as I know, you’re one of those people who has power to influence things.

                Thanks again for your elaborate answers!

                Like

                1. Hi Denis,

                  Not a problem at all. I just wanted to understand whether there was something that couldn’t be addressed via the 2 env variables way.
                  As said, this is standard for many, many years now and seems to work quite well, hopefully also for your use case 🙂

                  Thx,

                  Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.