The How To has been extracted from the following link: http://www.joelennon.ie/2014/02/06/installing-oracle-instant-client-mac-os-x/
SQuirreL SQL Client is a JAVA-based database administration tool for JDBC compliant databases. It allows you to view the database structure and issue SQL commands. It supports databases such as Firebird, IBM DB2, InterBase, Microsoft Access, Microsoft SQL Server, MySQL, Oracle, PostreSQL, and Sybase.
Oracle Database Client Download
I just skipped some text and modified some paths to adapt it to oracle client 18.104.22.168 release.
1. Download the files from the Oracle Site
Be sure to grab the following two files:
- Instant Client Package – Basic
- Instant Client Package – SQL*Plus
2. Extract the files and create the proper folder structure.
Open a Terminal window and unzip the downloaded files.
$ unzip -qq instantclient-basic-macos.x64-22.214.171.124.0.zip
$ unzip -qq instantclient-sqlplus-macos.x64-126.96.36.199.0.zip
Note: The -qq flag will tell the unzip utility to run in quieter mode, preventing any output from being displayed on the screen.
By default, the archive will extract all these files to a single directory. Instead, we’ll create a nicely structured directory to keep these files in your user Applications folder.
$ mkdir -p /Applications/oracle/product/instantclient_64/188.8.131.52.0/bin
$ mkdir -p /Applications/oracle/product/instantclient_64/184.108.40.206.0/lib
$ mkdir -p /Applications/oracle/product/instantclient_64/220.127.116.11.0/jdbc/lib
$ mkdir -p /Applications/oracle/product/instantclient_64/18.104.22.168.0/rdbms/jlib
$ mkdir -p /Applications/oracle/product/instantclient_64/22.214.171.124.0/sqlplus/admin
$ mkdir -p /Applications/oracle/product/instantclient_64/126.96.36.199.0/network/admin
Next, move the files over to these directories as follows:
$ cd instantclient_11_2
$ mv ojdbc* /Applications/oracle/product/instantclient_64/188.8.131.52.0/jdbc/lib/
Best Oracle Database Client For Mac
$ mv x*.jar /Applications/oracle/product/instantclient_64/184.108.40.206.0/rdbms/jlib/
$ mv glogin.sql /Applications/oracle/product/instantclient_64/220.127.116.11.0/sqlplus/admin/
$ mv *dylib* /Applications/oracle/product/instantclient_64/18.104.22.168.0/lib/
$ mv *README /Applications/oracle/product/instantclient_64/22.214.171.124.0/
$ mv * /Applications/oracle/product/instantclient_64/126.96.36.199.0/bin/
3. Create a proper tnsnames.ora file to define proper connection strings
Copy or create a tnsnames.ora file to /Applications/oracle/product/instantclient_64/188.8.131.52.0/network/admin/
Create the tnsnames.ora file with the vi editor, paste the following lines and save it.
(You can better ask to a DBA to review the content of this file and ask her to provide you with a proper test connection)
4. Set up environment variables
Edit or create a file .bash_profile
$ cd /Users/UserName
$ vi ~/.bash_profile
if you haven’t created a .bash_profile before the file will be empty, otherwise just add the following lines to the end of the existing file.
To load this profile, run the following command:
$ source ~/.bash_profile
Assuming you have set up your tnsnames.ora file correctly, you should now be able to connect one of the databases as follows:
5. Start using SQLPlus
$ sqlplus username/[email protected]
6. Did you enjoy? That’s all folks.
Fixing command history for using SQLPlus line edition with arrow keys
If you have used the command-line SQLPlus in a Windows environment, you will probably be used to using the command history to execute previous SQL statements using the arrow keys. One thing you’ll notice in SQLPlus for the Mac is that this doesn’t work by default, if you hit the up key you’ll see a strange character sequence ^[[A rather than the previous command. Let’s go ahead and fix this now.
To do this, you’ll need to use rlwrap. You could download this from source and build it yourself, but I find it much easier to use the fantastic brew package manager for Mac OS X. Head over to http://brew.sh/ and follow the instructions to install and set up Homebrew (it’s very easy). With Homebrew installed, you can now easily install rlwrap on your system with one command:
$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
$ brew install rlwrap
The final thing you need to do is tell your system to use rlwrap whenever you use SQL*Plus. To do that, you’ll need to edit your .bash_profile file again.
$ vi ~/.bash_profile
Add the following line to the end of the file.
alias sqlplus=’rlwrap sqlplus’
Now reload the .bash_profile:
$ source ~/.bash_profile
Now, when you launch SQL*Plus and try to use the arrow keys to access previous commands, it will work.