Victor is a full stack software engineer who loves travelling and building things. Most recently created Ewolo, a cross-platform workout logger.
How to connect to an Oracle database on Ubuntu

I recently had to work on a project that was pulling data from an Oracle database. While there are many tutorials on installing the relevant drivers, I needed a simple setup that would work across multiple programming languages. Here are the instructions for installing the latest Oracle drivers on Ubuntu 18.04 and above:

  • Download the Oracle 18 "Basic" zip file along with the SDK zip file. Note that you would need to register with Oracle first to be able to download.
  • Unzip the files to somewhere accessible:
    sudo mkdir -p /opt/oracle
    cd /opt/oracle
    sudo mv ~/Downloads/ .
    sudo mv ~/Downloads/ .
    sudo unzip
    sudo unzip
  • Note that the last command will unzip the sdk under the /opt/oracle/instantclient_18_3/sdk folder.
  • Install random dependency (note that on some systems it is libaio1): sudo apt install libaio
  • Permanently add Instant Client to the runtime link path:
    sudo sh -c "echo /opt/oracle/instantclient_18_3 > /etc/"
    sudo ldconfig
  • For maximum compatibility you should co-locate the Oracle configuration files such as tnsnames.ora, sqlnet.ora, etc., with the instant client. Create the following directory and put them in there: mkdir -p /opt/oracle/instantclient_18_3/network/admin

The above should be enough to allow you to install the relevant drivers for your programming language environment and get coding. Finally, note that Version 18 and 12.2 client libraries can connect to Oracle Database 11.2 or greater. Version 12.1 client libraries can connect to Oracle Database 10.2 or greater. Version 11.2 client libraries can connect to Oracle Database 9.2 or greater.

Maximum credit for this tutorial goes to the python cx_oracle module installation documentation!