Run Oracle Sql Client For Mac

In addition to using the Oracle Database XE graphical user interface to work with the database, you can use the set of command-line utilities that come with Oracle Database XE. Table 3-1 lists these utilities. To use these utilities, you must understand how to connect to the database with them.

  1. Oracle Sql Client Download

Table 3-1 Oracle Database XE Command-Line Utilities

UtilityPurposeSee Also

SQL Command Line (SQL*Plus)

Administer the database; create, alter and drop database objects; run SQL queries; and run SQL and PL/SQL scripts.

'Using SQL Command Line' in Oracle Database Express Edition 2 Day Developer Guide

Data Pump

Export and import data from one Oracle database to another.


Import and Export

Export and import data from one Oracle database to another.


SQL*Loader

Bulk-load data into the database from external files.



Although connection concepts apply to all utilities, this section focuses on SQL Command Line (SQL*Plus), because you use it for database administration. The following topics are covered:

This step means that every time you open a Terminal, you can run SQL*Plus against the Oracle Database in the VM instance. Naturally, you’ll need the VM instance up and running concurrently. How to configure Mac OS X as an Oracle Client [] Reflecting on six months of blogg’n « Maclochlainn’s Weblog. October 17, 2008 at 11:05 pm. How to connect to Oracle 11g using Oracle-SQL-Developer from a Mac up vote 1 down vote favorite I am currently running Oracle 11g on my Windows 10 machine, but I use my mac a lot and I want to connect to the installed Oracle 11g on my windows from my mac using SQLDeveloper. A tutorial on how you install Oracle 10g Client software on the Mac OS X platform. You’ll be able to run SQL*Plus from the Mac OS command-line, SQL*Developer.

Oracle

See Also:

The following documents, for information on how to connect to the database from your application:

About Local and Remote Connections

­Oracle Database XE supports connections between SQL Command Line (SQL*Plus) and the database either locally, or remotely over a TCP/IP network. The method that you use to connect to Oracle Database XE with SQL Command Line depends on whether you are initiating a local connection or a remote connection. Local and remote connections are explained in the following sections:

See Also:

  • 'Managing Network Connections' for information on how Oracle Database XE accepts connection requests over the network.

About Local Connections

Connecting locally means running SQL Command Line (or any other Oracle command-line utility) on the same host computer where Oracle Database XE is installed (the 'Oracle Database XE host computer') and then initiating a database connection from SQL Command Line (or other utility). To connect locally, you must supply only a database user name and password. For example, Figure 3-1 shows a user connecting locally with SQL Command Line and entering a connect command that supplies the user name hr and password hr.

Figure 3-1 Local Connection


Description of 'Figure 3-1 Local Connection'

Environment Variables

Before making a local connection on Linux, you must set environment variables. See 'Setting Environment Variables' for more information.

Note:

Logging in to the Oracle Database XE host computer with an ssh (or telnet) session and then starting SQL Command Line (or other Oracle command-line utility) is considered a local connection, even though you start the ssh (or telnet) application on a remote computer.

About Remote Connections

Connecting remotely means running SQL Command Line (or any other Oracle command-line utility) on a computer other than the Oracle Database XE host computer, and then initiating a database connection from SQL Command Line (or other utility) over the network.

Oracle Client Software

The remote computer must have Oracle client software installed. It is through Oracle client software that Oracle command-line utilities (and your applications) connect to the database. Oracle Database XE accepts connections from all of the following types of Oracle client software:

  • Oracle Database Express Edition Client (Oracle Database XE Client)

    When you install Oracle Database XE, Oracle Database XE Client is also installed on the same computer. You can install Oracle Database XE Client separately on remote computers. It is available at

  • Instant Client

    Instant Client is available at

  • Oracle client software for Oracle Database Enterprise Edition or Standard Edition (all supported releases of Oracle Database 8, 8i, 9i, and 10g)

All Oracle client software includes Oracle Net, which is the Oracle network software that enables client applications on one computer to connect to databases on another computer over a network.

Oracle Sql Client Download

Connect Strings

To connect remotely, you must supply not just a user name and password, but a complete Oracle Net connect string. In addition to the database user name and password, a connect string includes a host name or host IP address, an optional TCP port number, and an optional database service name. These additional parameters are required to help Oracle Net find the right host computer and connect to Oracle Database XE. An Oracle Net connect string has the following format:

where:

  • // is optional

  • host is the host name or IP address of the computer that is running Oracle Database XE

  • port (optional) is the TCP port number on which the Oracle Net listener is listening. If not specified, the default port number 1521 is assumed.

  • service_name (optional) is the name of the database service to which to connect. For Oracle Database XE, the service name is XE. If service_name is omitted, Oracle Database XE Client appends a request for the default database service, which is configured during installation as XE.

Note:

Only Oracle Database XE Client supports the notion of a default database service. If you connect remotely from any Oracle client software other than Oracle Database XE Client, you must include the XE service name.

For example, Figure 3-2 shows a user connecting remotely with SQL Command Line and entering a connect command that includes a connect string that supplies: the user name hr, the password hr, and the host name dbhost.xyz.com. This connect string connects to the default database service (XE) on the default port (1521).

Figure 3-2 Remote Connection


Description of 'Figure 3-2 Remote Connection'

Environment Variables

Before making a remote connection from Linux, you must set environment variables. See 'Setting Environment Variables' for more information.

Remote Connection Examples

In the following examples of SQL Command Line connect commands, Oracle Database XE is running on the host computer mydbserver.mydomain.com.

Example 1 This example initiates a remote connection from Oracle Database XE Client, using the default port number.

Example 2 This example initiates a remote connection from Oracle Database XE Client, using a nondefault port number (1522):

Example 3 This example initiates a remote connection using the default port number, and includes the optional service name.

Setting Environment Variables

SQL Command Line (SQL*Plus) and other Oracle utilities retrieve configuration information from operating system environment variables. This section explains how to set these environment variables, and contains the following topics:

Setting Environment Variables on the Windows Platform

On the Windows platform, environment variables are stored in the Windows registry, and are automatically set for you. You need not take any action involving environment variables before initiating a database connection.

Setting Environment Variables on the Linux Platform

On the Linux platform, before running SQL Command Line or other Oracle utilities from a terminal session, you must set some environment variables for that session. The procedure for setting environment variables depends on whether you are connecting locally, or connecting remotely from Oracle Database XE Client.

Setting Environment Variables for a Local Connection

To set environment variables when connecting locally, enter one of the following commands in a terminal session.

For Bourne, Korn, or Bash shell:

For C shell:

See 'Environment Variables Reference for Linux' for more information.

Note:

There is no need to set environment variables before running SQL Command Line from the K menu (KDE) or Applications menu (Gnome).

Setting Environment Variables for a Remote Connection

To set environment variables when connecting remotely from Oracle Database XE Client, enter one of the following commands in a terminal session at the remote computer:

For Bourne, Korn, or Bash shell:

For C shell:

See 'Environment Variables Reference for Linux' for more information.

See Also:

Connecting Locally with SQL Command Line

Connecting locally means running SQL Command Line (SQL*Plus) and Oracle Database XE on the same computer. There are two ways to start a local connection with SQL Command Line:

  • From the desktop

  • From a terminal session (Linux) or command window (Windows)

Starting SQL Command Line from the Desktop

To start SQL Command Line from the desktop and connect locally:

  1. Do one of the following:

    • On Windows: Click Start, point to Programs (or All Programs), point to Oracle Database 10g Express Edition, and then select Run SQL Command Line.

    • On Linux with Gnome: In the Applications menu, point to Oracle Database 10g Express Edition, and then select Run SQL Command Line.

    • On Linux with KDE: Click the icon for the K Menu, point to Oracle Database 10g Express Edition, and then select Run SQL Command Line.

    A SQL Command Line command window opens.

  2. At the SQL Command Line prompt, enter the following command:

    For example, to connect as user HR with the password PEOPLE, enter the following command:

Starting SQL Command Line from a Terminal Session or Command Window

To start SQL Command Line from a terminal session or command window and connect locally:

  1. If not already open, open a terminal session (Linux) or a command window (Windows).

  2. (Linux only) If the required environment variables are not already set for your session, set them as described in 'Setting Environment Variables on the Linux Platform'.

  3. Enter the following command at the operating system prompt:

  4. At the SQL Command Line prompt, enter the following command:

    For example, to connect as user HR with the password PEOPLE, enter the following command:

See Also:

Connecting Remotely with SQL Command Line

Connecting remotely means running SQL Command Line (SQL*Plus) on one computer (the remote computer), and then initiating a connection to Oracle Database XE on a different computer.

To initiate a remote connection from SQL Command Line using the Oracle Database XE Client:

  1. On the remote computer, start a terminal session (Linux) or open a command window (Windows.)

    If prompted for host credentials, log in to the remote computer.

  2. (Linux only) If the required environment variables are not already set for your session, set them as described in 'Setting Environment Variables on the Linux Platform'.

  3. Enter the following command at the operating system prompt:

  4. Enter a CONNECT command at the SQL Command Line prompt, supplying a connect string.

    See 'About Remote Connections' for a description and examples of connect strings.

Environment Variables Reference for Linux

This section provides reference information for setting environment variables on Linux for the following two scenarios:

  • Connecting locally

  • Connecting remotely from Oracle Database XE Client.

Table 3-2 lists the environment variables that you must set for each of these scenarios. Table 3-3 provides environment variable descriptions and required values.

Table 3-2 Required Linux Environment Variables for Connecting with Oracle Utilities

Connection TypeRequired Environment Variables

Local


ORACLE_SID
ORACLE_HOME
PATH
NLS_LANG
LD_LIBRARY_PATH

Remote, using Oracle Database XE Client


ORACLE_HOME
PATH
NLS_LANG
LD_LIBRARY_PATH
SQLPATH

Table 3-3 Environment Variable Descriptions and Values for Linux

Variable NameDescriptionRequired Value

ORACLE_SID

Oracle Instance ID

XE

ORACLE_HOME

Oracle home directory

For local connection:

/usr/lib/oracle/xe/app/oracle/product/10.2.0/server

For remote connection with Oracle Database XE Client:

/usr/lib/oracle/xe/app/oracle/product/10.2.0/client

PATH

Search path for executables. (Must add $ORACLE_HOME/bin to the path.)

For Bourne, Korn, or Bash shell: $ORACLE_HOME/bin:$PATH

For C shell: $ORACLE_HOME/bin:${PATH}

NLS_LANG

Locale (language and territory used by client applications and the database; character set used by client applications)

(The desired language, territory, and character set. See Oracle Database Express Edition Installation Guide for Linux for details.)

Defaults to AMERICAN_AMERICA.US7ASCII

LD_LIBRARY_PATH

Search path for shared libraries. (Must add $ORACLE_HOME/lib to the path.

$ORACLE_HOME/lib:$LD_LIBRARY_PATH

SQLPATH

Search path used by SQL Command Line (SQL*Plus) for *.sql scripts. Contains a colon-separated list of paths. Must include the location of the site profile script, glogin.sql.

$ORACLE_HOME/sqlplus/admin


Example

The following are the Bash shell commands that set the required environment variables for a local connection on a Linux installation in the United States:

Environment Variable Scripts

Oracle Database XE and Oracle Database XE Client ship with two shell scripts that you can use to easily set environment variables. The scripts are located in $ORACLE_HOME/bin and are named as follows:


oracle_env.sh (for Bourne, Korn, or Bash shell)
oracle_env.csh (for C shell)

You can invoke these scripts from within dot files so that environment variables are set automatically each time that you start a new terminal session (start a new shell). The following is an example of a command that you can add to the .cshrc file in your home directory:

Active4 years, 9 months ago

I want to install SqlPlus client on my Mac, which is 64-bit.Firstly, I installed sqlplus for 64-bit, but I had error:'Segmentation fault: 11'Then I installed sqlplus for 32-bit, but still have a problem it says:../libsqlplus.dylib: no suitable image found ../libsqlplus.dylib: mach-o, but wrong architecture

I have used many tutorials, but still didn't solve this problem.

Ryainad
RyainadRyainad
1041 gold badge3 silver badges12 bronze badges

1 Answer

The 11gR2 64-bit instant client works on 10.8.5. It doesn't matter if the database you're connecting to is still 10g, you can use the 11g client. I'm not aware of any reason to still use the old version, unless maybe you need a specific ojdbc version; but presumably there are use cases or it wouldn't still be listed prominently for download. Anyway, this demonstrates a fresh install:

You can create a tnsnames.ora anywhere; I put this in the same instant client_11_2 directory:

The 32-bit version works fine too:

You can of course move or rename the instanstclient_11_2 directory to anything you want, just make sure your DYLD_LIBRARY_PATH, TNS_ADMIN and (to make life easier) PATH environment variables follow it. If you have more than one version installed make sure the variables only point to one version at a time so you pick up the right libraries etc. (If you do have multiple versions, making TNS_ADMIN somewhere central makes much more sense as you only need to maintain one copy of tnsnames.ora).

I'd need to check, but I think you might have to still use the 32-bit version if you're connecting from Java; it has to batch the architecture of Java itself so I guess it depends which version of that you have installed.

Alex PooleAlex Poole
142k7 gold badges117 silver badges199 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged macosoracle32bit-64bitsqlplus or ask your own question.