{"id":203,"date":"2007-10-21T14:26:43","date_gmt":"2007-10-21T13:26:43","guid":{"rendered":"http:\/\/www.spikesoft.ch\/?p=203"},"modified":"2007-10-21T14:26:43","modified_gmt":"2007-10-21T13:26:43","slug":"sqlplus-installation","status":"publish","type":"post","link":"https:\/\/www.spikesoft.ch\/?p=203","title":{"rendered":"SQL*Plus installation"},"content":{"rendered":"<p>So far you&#8217;ve learned how to <a href=\"http:\/\/www.spikesoft.ch\/?p=155\">install an Oracle 11g Database<\/a>, how to <a href=\"http:\/\/www.spikesoft.ch\/?p=186\">access it from your Mac<\/a> with SQLDeveloper and now the last missing part of the puzzle for a comfortable work is SQL*Plus. It&#8217;s not the sexiest tool of Oracle, but it&#8217;s the one you&#8217;ll find on every machine that is able to do some serious work. So let&#8217;s see how to install SQL*Plus on your Mac.<\/p>\n<p><u><strong>01. Prerequisite<\/strong><\/u><\/p>\n<ul>\n<li><span class=\"boldbodycopy\"><em>Instant Client Package &#8211; Basic<\/em> from <a href=\"http:\/\/www.oracle.com\/technology\/software\/tech\/oci\/instantclient\/htdocs\/macsoft.html\" target=\"_blank\">Instant Client Downloads for Mac OS X<\/a><\/span><\/li>\n<li><em><span class=\"boldbodycopy\">Instant Client Package &#8211; SQL*Plus<\/span><\/em><span class=\"boldbodycopy\"> from <a href=\"http:\/\/www.oracle.com\/technology\/software\/tech\/oci\/instantclient\/htdocs\/macsoft.html\" target=\"_blank\">Instant Client Downloads for Mac OS X<\/a><\/span><\/li>\n<li><span class=\"boldbodycopy\">You use tcsh as shell<\/span><\/li>\n<\/ul>\n<p>Don&#8217;t be afraid if the download page says PowerPC it will also run on your brand new Intel Mac.<\/p>\n<p><u><strong>02. Installation<\/strong><\/u><\/p>\n<ol>\n<li>Create a directory to save all the needed libraries and programs. I personnaly chose to create this directory in <code>\/usr\/local\/bin<\/code>.\n<pre>sudo mkdir \/usr\/local\/bin\/oracle<\/pre>\n<\/li>\n<li>Change the owner of the newly created user to your current user.\n<pre>sudo chown your_user \/usr\/local\/bin\/oracle<\/pre>\n<\/li>\n<li>Open the oracle directory in the finder.\n<pre>open \/usr\/local\/bin\/oracle<\/pre>\n<\/li>\n<li>Copy the following elements in the folder:\n<ul>\n<li>sqlplus                      from <em><span class=\"boldbodycopy\">Instant Client Package &#8211; SQL*Plus <\/span><\/em><span class=\"boldbodycopy\">package<\/span><\/li>\n<li><span class=\"boldbodycopy\">libsqlplus.dylib       from <\/span><em><span class=\"boldbodycopy\">Instant Client Package &#8211; SQL*Plus <\/span><\/em><span class=\"boldbodycopy\">package<\/span><\/li>\n<li><span class=\"boldbodycopy\">libociei.dylib           from <\/span><span class=\"boldbodycopy\"><em>Instant Client Package &#8211; Basic <\/em>package<\/span><\/li>\n<li><span class=\"boldbodycopy\">libclntsh.dylib.10.1 <\/span><span class=\"boldbodycopy\">from <\/span><span class=\"boldbodycopy\"><em>Instant Client Package &#8211; Basic <\/em>package<\/span><\/li>\n<li><span class=\"boldbodycopy\">libsqlplus.dylib       <\/span><span class=\"boldbodycopy\">from <\/span><span class=\"boldbodycopy\"><em>Instant Client Package &#8211; Basic <\/em>package<\/span><\/li>\n<li><span class=\"boldbodycopy\">libnnz10.dylib         <\/span><span class=\"boldbodycopy\">from <\/span><span class=\"boldbodycopy\"><em>Instant Client Package &#8211; Basic <\/em>package<\/span><a href=\"http:\/\/www.spikesoft.ch\/wordpress\/upload\/2007\/10\/oracle_dir.jpg\"><img decoding=\"async\" src=\"http:\/\/www.spikesoft.ch\/wordpress\/upload\/2007\/10\/oracle_dir.jpg\" width=\"400\" \/><\/a><\/li>\n<\/ul>\n<\/li>\n<li>Edit you <code>.cshrc<\/code> and add the following lines:\n<pre>\r\nsetenv DYLD_LIBRARY_PATH \/usr\/local\/bin\/oracle\r\nsetenv ORACLE_HOME       \/usr\/local\/bin\/oracle\r\nsetenv TNS_ADMIN         \/usr\/local\/bin\/oracle\r\nsetenv PATH              \/usr\/local\/bin\/oracle:$PATH<\/pre>\n<\/li>\n<li>Add in the oracle directory a file <code>tnsnames.ora<\/code> with the following content where the name after the HOST = part (on the 3rd line) is the hostname of the instance running your database:\n<pre>\r\nORCL = (DESCRIPTION =\r\n  (ADDRESS = (PROTOCOL = TCP)(HOST = oracle)(PORT = 1521))\r\n  (CONNECT_DATA =\r\n    (SERVER = DEDICATED)\r\n    (SERVICE_NAME = orcl)\r\n  )\r\n)<\/pre>\n<\/li>\n<li>You can now open a new terminal and connect to your database instance by issuing:\n<pre>sqlplus scott@orcl<\/pre>\n<\/li>\n<\/ol>\n<p><u><strong>03. Nice to have<\/strong><\/u><\/p>\n<ul>\n<li>As you certainly knows if you use a bit the standard SQL*Plus, it&#8217;s an absoute pain that you don&#8217;t have any line editing option or any history except the last executed command. Hopefully you&#8217;re in a Unix environement and you have the utility <a href=\"http:\/\/utopia.knoware.nl\/~hlub\/rlwrap\/\" target=\"_blank\">rlwrap<\/a> that does exactly what you need. Install it with <a href=\"http:\/\/finkproject.org\/\" target=\"_blank\">fink<\/a> (you first have to update your package repository in order to find the rlwarp package). Once rlwrap is installed add the following line to your <code>.cshrc<\/code>:\n<pre>  alias sqlplus 'rlwrap sqlplus'<\/pre>\n<p>Now you can enjoy an Unix like SQL*Plus.<\/li>\n<li>You can save your oracle directory to be an absolute mess by moving all your scripts into another directory. I chose to create a scripts directory in my oracle directory. In order to tell SQL*Plus that you&#8217;ve such an organisation you have to add the following line to your <code>.cshrc<\/code>:\n<pre>\r\n  setenv SQLPATH           \/usr\/local\/bin\/oracle\/scripts<\/pre>\n<\/li>\n<li>Last but not least, as you&#8217;re a Mac user, you would like to use the best of your platform (inst&#8217;it). That is why instead of using the ugly vi or any other Unix text editor, you can use the only good text editor that exist for Mac: <a href=\"http:\/\/www.codingmonkeys.de\/subethaedit\/\" target=\"_blank\">SubEthaEdit<\/a>. Once you installed it go into Preferences under Advanced and install the command line tool. Once done add to your <code>login.sql<\/code> and <code>connect.sql<\/code> script the following line:\n<pre>  define _editor=see<\/pre>\n<p><a href=\"http:\/\/www.spikesoft.ch\/wordpress\/upload\/2007\/10\/see_cmd_tool.jpg\"><img decoding=\"async\" src=\"http:\/\/www.spikesoft.ch\/wordpress\/upload\/2007\/10\/see_cmd_tool.jpg\" \/><\/a><\/li>\n<\/ul>\n<p>Congratulations you just install SQL*Plus on the Mac. You now have a fully usable Oracle development environment with a bit of Mac taste.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So far you&#8217;ve learned how to install an Oracle 11g Database, how to access it from your Mac with SQLDeveloper and now the last missing part of the puzzle for a comfortable work is SQL*Plus. It&#8217;s not the sexiest tool &hellip; <a href=\"https:\/\/www.spikesoft.ch\/?p=203\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[],"class_list":["post-203","post","type-post","status-publish","format-standard","hentry","category-macintosh","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=\/wp\/v2\/posts\/203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=203"}],"version-history":[{"count":0,"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=\/wp\/v2\/posts\/203\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spikesoft.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}